obaluba
02-13-2007, 07:40 PM
I know this has been asked a hundred times, I've browsed previous threads but cant see an answer which will help me.
I have a simple form, which when filled out enters data into a database and sends a formmail email to me, confirming entry into the db.
What I would like to do is ensure that the user fills in certain fields, like firstname, lastname, address and email.
What would be the easiest way to do this? Is it something I would have to do on the form istelf or can it be done here?
My code is as follows:
The Store Form in database code:
<? // code for store_comment.php
// Database information required to connect to database
$host = "localhost";
$name = "cd";
$pass = "1234";
$dbname = "cd_join";
$message = "";
// Connect to Database and select the database to use
$dbi = mysql_connect($host,$name,$pass) or
die("I cannot connect to the database. Error :" . mysql_error());
mysql_select_db($dbname,$dbi);
// Get the values posted from the Form in Join.php
$title = $_POST["title"];
$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$dateofbirth = $_POST["dateofbirth"];
$address = $_POST["address"];
$county = $_POST["county"];
$postcode = $_POST["postcode"];
$mobile_no = $_POST["mobile_no"];
$home_no = $_POST["home_no"];
$email_address = $_POST["email_address"];
$forumusername = $_POST["forumusername"];
$hearaboutaoc = $_POST["hearaboutaoc"];
$model = $_POST["model"];
$vehicle_year = $_POST["vehicle_year"];
$enginesize = $_POST["enginesize"];
$colour = $_POST["colour"];
$registration = $_POST["registration"];
$membershiptype = $_POST["membershiptype"];
$paymenttype = $_POST["paymenttype"];
if ($firstname != "" ) {
$message = "Please enter a First Name.";
}
// Insert the Details into the Database
$sql = "INSERT INTO join (title,firstname,lastname,dateofbirth,address,county,postcode,mobile_no,home_no,email_address,forumu sername,hearaboutaoc,model,vehicle_year,enginesize,colour,registration,membershiptype,paymenttype) VALUES
('$title','$firstname','$lastname','$dateofbirth','$address','$county','$postcode','$mobile_no','$ho me_no','$email_address','$forumusername','$hearaboutaoc','$model','$vehicle_year','$enginesize','$co lour','$registration','$membershiptype','$paymenttype')";
$result = mysql_query($sql,$dbi);
// Formmail Section
$mailto = 'rrr@rr.com' ;
$subject = "Membership Request" ;
$formurl = "http://www.cd1.co.uk/index.php" ;
$errorurl = "http://www.cd1.co.uk/index.php" ;
$thankyouurl = "http://www.cd1.co.uk/join_payment.php" ;
$title = $_POST["title"];
$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$dateofbirth = $_POST["dateofbirth"];
$address = $_POST["address"];
$county = $_POST["county"];
$postcode = $_POST["postcode"];
$mobile_no = $_POST["mobile_no"];
$home_no = $_POST["home_no"];
$email_address = $_POST["email_address"];
$forumusername = $_POST["forumusername"];
$hearabout = $_POST["hearabout"];
$model = $_POST["model"];
$vehicle_year = $_POST["vehicle_year"];
$enginesize = $_POST["enginesize"];
$colour = $_POST["colour"];
$registration = $_POST["registration"];
$membershiptype = $_POST["membershiptype"];
$paymenttype = $_POST["paymenttype"];
$http_referrer = getenv( "HTTP_REFERER" );
$messageproper =
"------------------------- Membership Request Submission Form -------------------------\n\n" .
"Title: $title" .
"\n\n" .
"Firstname: $firstname" .
"\n\n" .
"Lastname: $lastname" .
"\n\n" .
"Date Of Birth: $dateofbirth" .
"\n\n" .
"Address: $address" .
"\n\n" .
"County: $county" .
"\n\n" .
"Postcode: $postcode" .
"\n\n" .
"Mobile Number: $mobile_no" .
"\n\n" .
"Home Number: $home_no" .
"\n\n" .
"Email Address: $email_address" .
"\n\n" .
"Forum Username: $forumusername" .
"\n\n" .
"How Did you Hear about AOC: $hearaboutaoc" .
"\n\n" .
"Vehicle Model: $model" .
"\n\n" .
"Vehicle Year: $vehicle_year" .
"\n\n" .
"Engine Size: $enginesize" .
"\n\n" .
"Colour: $colour" .
"\n\n" .
"Registration: $registration" .
"\n\n" .
"Membership Type: $membershiptype" .
"\n\n" .
"Payment Type: $paymenttype" .
"\n\n" .
"\n\n------------------------------------------------------------\n" ;
mail($mailto, $subject, $messageproper, "From: \"$firstname $lastname\" <$email_address>\nReply-To: \"$firstname\" <$email_address>\nX-Mailer: chfeedback.php 2.01" );
header( "Location: $thankyouurl" );
exit ;
?>
thanks for looking :)
I have a simple form, which when filled out enters data into a database and sends a formmail email to me, confirming entry into the db.
What I would like to do is ensure that the user fills in certain fields, like firstname, lastname, address and email.
What would be the easiest way to do this? Is it something I would have to do on the form istelf or can it be done here?
My code is as follows:
The Store Form in database code:
<? // code for store_comment.php
// Database information required to connect to database
$host = "localhost";
$name = "cd";
$pass = "1234";
$dbname = "cd_join";
$message = "";
// Connect to Database and select the database to use
$dbi = mysql_connect($host,$name,$pass) or
die("I cannot connect to the database. Error :" . mysql_error());
mysql_select_db($dbname,$dbi);
// Get the values posted from the Form in Join.php
$title = $_POST["title"];
$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$dateofbirth = $_POST["dateofbirth"];
$address = $_POST["address"];
$county = $_POST["county"];
$postcode = $_POST["postcode"];
$mobile_no = $_POST["mobile_no"];
$home_no = $_POST["home_no"];
$email_address = $_POST["email_address"];
$forumusername = $_POST["forumusername"];
$hearaboutaoc = $_POST["hearaboutaoc"];
$model = $_POST["model"];
$vehicle_year = $_POST["vehicle_year"];
$enginesize = $_POST["enginesize"];
$colour = $_POST["colour"];
$registration = $_POST["registration"];
$membershiptype = $_POST["membershiptype"];
$paymenttype = $_POST["paymenttype"];
if ($firstname != "" ) {
$message = "Please enter a First Name.";
}
// Insert the Details into the Database
$sql = "INSERT INTO join (title,firstname,lastname,dateofbirth,address,county,postcode,mobile_no,home_no,email_address,forumu sername,hearaboutaoc,model,vehicle_year,enginesize,colour,registration,membershiptype,paymenttype) VALUES
('$title','$firstname','$lastname','$dateofbirth','$address','$county','$postcode','$mobile_no','$ho me_no','$email_address','$forumusername','$hearaboutaoc','$model','$vehicle_year','$enginesize','$co lour','$registration','$membershiptype','$paymenttype')";
$result = mysql_query($sql,$dbi);
// Formmail Section
$mailto = 'rrr@rr.com' ;
$subject = "Membership Request" ;
$formurl = "http://www.cd1.co.uk/index.php" ;
$errorurl = "http://www.cd1.co.uk/index.php" ;
$thankyouurl = "http://www.cd1.co.uk/join_payment.php" ;
$title = $_POST["title"];
$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$dateofbirth = $_POST["dateofbirth"];
$address = $_POST["address"];
$county = $_POST["county"];
$postcode = $_POST["postcode"];
$mobile_no = $_POST["mobile_no"];
$home_no = $_POST["home_no"];
$email_address = $_POST["email_address"];
$forumusername = $_POST["forumusername"];
$hearabout = $_POST["hearabout"];
$model = $_POST["model"];
$vehicle_year = $_POST["vehicle_year"];
$enginesize = $_POST["enginesize"];
$colour = $_POST["colour"];
$registration = $_POST["registration"];
$membershiptype = $_POST["membershiptype"];
$paymenttype = $_POST["paymenttype"];
$http_referrer = getenv( "HTTP_REFERER" );
$messageproper =
"------------------------- Membership Request Submission Form -------------------------\n\n" .
"Title: $title" .
"\n\n" .
"Firstname: $firstname" .
"\n\n" .
"Lastname: $lastname" .
"\n\n" .
"Date Of Birth: $dateofbirth" .
"\n\n" .
"Address: $address" .
"\n\n" .
"County: $county" .
"\n\n" .
"Postcode: $postcode" .
"\n\n" .
"Mobile Number: $mobile_no" .
"\n\n" .
"Home Number: $home_no" .
"\n\n" .
"Email Address: $email_address" .
"\n\n" .
"Forum Username: $forumusername" .
"\n\n" .
"How Did you Hear about AOC: $hearaboutaoc" .
"\n\n" .
"Vehicle Model: $model" .
"\n\n" .
"Vehicle Year: $vehicle_year" .
"\n\n" .
"Engine Size: $enginesize" .
"\n\n" .
"Colour: $colour" .
"\n\n" .
"Registration: $registration" .
"\n\n" .
"Membership Type: $membershiptype" .
"\n\n" .
"Payment Type: $paymenttype" .
"\n\n" .
"\n\n------------------------------------------------------------\n" ;
mail($mailto, $subject, $messageproper, "From: \"$firstname $lastname\" <$email_address>\nReply-To: \"$firstname\" <$email_address>\nX-Mailer: chfeedback.php 2.01" );
header( "Location: $thankyouurl" );
exit ;
?>
thanks for looking :)