Log in

View Full Version : adding more info on PHP form



PFM
09-08-2006, 02:24 PM
Hi

I have been trying to add a few more lines (info) to a PHP form bascially to have info as per below;Info comes from HTML page 'advertisement form' then once filled in and submitted a thank you page appears

name
business name
website
email address
advertisement category
comments

I have so far added (i hope) business name and website to this form as per below. Could somebody let me know that I am on the right track? thank you


$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$business name = $_POST['business name'] ;
$website = $_POST['website'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
}

if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}

$messageproper =

"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n" .
"Email of sender: $email\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;

mail($mailto, $subject, $messageproper,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer:

chfeedback.php 2.07" );
header( "Location: $thankyouurl" );
exit ;

?>

thetestingsite
09-08-2006, 03:01 PM
Now is the above code the entire program, or just a part of it. The only problems that I could see is a few variables that are not in the code above. But if its not the whole thing, just ignore what I just said. Other than that it should work.

PFM
09-09-2006, 02:34 AM
Hi

This is the PHP part of the form, the other part is the actual HTML page which is called AdvertiseForm.html with the tables on etc, then a Thank you (thankyou.html) page that appears after filling out the form (if this is what you mean't)?

Please let me know if I somehow? need to add the additional selections of Business name - Website - Advertising Category to the code below which is part of the form sent in email below this email, for this form to work?

Also please find attached the HTML page which will be (Advertiseform.html) at the moment it is called (thankyou2.html) this is attached as a ZIP Folder.

Thank you for your help

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
}

if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );

thetestingsite
09-13-2006, 01:34 AM
one thing that I have noticed in the beginning (<< spelling?) part of the php code, heres your code:


$name = $_POST['name'] ;
$business name = $_POST['business name'] ;
$website = $_POST['website'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

when it should actually be like this:


$name = $_POST['name'];
$business = $_POST['business'];
$website = $_POST['Website'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$advert = $_POST['Advert'];
$http_referrer = getenv( "HTTP_REFERER" );

Other than those points of interest, the rest should work as planned. If you still need any help, let me know and also, sorry I did not get to this sooner. I have been extremely busy at work.