Forum Moderators: coopster

Message Too Old, No Replies

Could someone show me how to make a form handler?

         

naitsirhc26

8:43 am on Aug 15, 2006 (gmt 0)

10+ Year Member



I am really stumpt. I have tried and tried, but I can't seem to make a php form handler. I would love it to be able to check for required fields, and to be able to show the viewer their information before it is submitted, so they can make changes before it is submitted. Please let me know if someone could help me make one. Thanks.

naitsirhc26

8:56 am on Aug 15, 2006 (gmt 0)

10+ Year Member



I would also love it to be able to redirect visitors to my homepage.

le_gber

9:06 am on Aug 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



try looking in your favourite search engine for php form verification or php form validation. You should get enough tutorials to help you out.

Once you've customised your code, come back to WebmasterWorld PHP forum [webmasterworld.com] and ask any question that you like / have problem with.

trillianjedi

9:14 am on Aug 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As le_gber mentions, you're probably in the wrong forum for this.

I have tried and tried, but I can't seem to make a php form handler

Post your code (as far as you got) over in the PHP forum - I'm sure there are plenty of people who can help you fix it.

TJ

BeeDeeDubbleU

9:54 am on Aug 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



... or Google tools4php. (A great time saver)

naitsirhc26

3:50 pm on Aug 15, 2006 (gmt 0)

10+ Year Member



This is the code I have so far. I would like to make it more interactive, and I would like to be able to redirect users to the home page. The form processor must be able to process anything that is in the form.

<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
// In testing, if you get an Bad referer error
// comment out or remove the next three lines
if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])>7 ¦¦
!strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']))
die("Bad referer");
$msg="Values submitted by the user:\n";
foreach($_POST as $key => $val){
if (is_array($val)){
$msg.="Item: $key\n";
foreach($val as $v){
$v = stripslashes($v);
$msg.=" $v\n";
}
} else {
$val = stripslashes($val);
$msg.="$key: $val\n";
}
}
$recipient="<snip>";
$subject="<snip>";
error_reporting(0);
if (mail($recipient, $subject, $msg)){
echo "<center><h1>Thank you</h1><p>Message successfully sent!</p></center>\n";
echo nl2br($input);
} else
echo "An error occurred and the message could not be sent.";
} else
echo "Bad request method";

?>

[edited by: trillianjedi at 4:00 pm (utc) on Aug. 15, 2006]
[edit reason]
[1][edit reason] No specifics please ;) [/edit]
[/edit][/1]

BeeDeeDubbleU

3:53 pm on Aug 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



tools4php will do all of this for $25.00. How much is your time worth? ;)

naitsirhc26

4:09 pm on Aug 15, 2006 (gmt 0)

10+ Year Member



Well, all I need is for the text to look more formatted on my end of the form, protection from spammers, and to have the visitors redirected after they enter the information. Can someone do that?

jatar_k

5:06 pm on Aug 15, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try the threads in our PHP Library [webmasterworld.com]

specifically
Basics of Submitting and Emailing Forms with PHP [webmasterworld.com]
Combatting Webform hijack [webmasterworld.com]