dnbhead22 Posted April 3, 2012 Share Posted April 3, 2012 when i click submit the form isnt sending to the dataabse...any help really appreciated!! heres the code: <?php session_start(); $errorMsg = ""; if (isset($_POST['billing'])){ include_once "connect_to_mysql.php"; $firstname = preg_replace("[^A-Za-z0-9]", "", $_POST['firstname']); $lastname = preg_replace("[^A-Z a-z0-9]", "", $_POST['Last Name']); $address = preg_replace("[^A-Z a-z0-9]", "", $_POST['address']); $phone = preg_replace("[^A-Z a-z0-9]", "", $_POST['phone']); $creditcard = preg_replace("[^A-Z a-z0-9]", "", $_POST['creditcard']); $expiry = preg_replace("[^A-Z a-z0-9]", "", $_POST['expiry']); $CVV = preg_replace("[^A-Z a-z0-9]", "", $_POST['CVV']); $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); if((!$firstname) || (!$lastname) || (!$address) || (!$phone) || (!$creditcard) || (!$expiry) || (!$CVV) || (!$email)){ $errorMsg = "You did not submit the following required information!<br /><br />"; if(!$firstname){ $errorMsg .= "--- First Name"; } else if(!$lastname){ $errorMsg .= "--- Last Name"; } else if(!$address){ $errorMsg .= "--- Address"; } else if(!$phone){ $errorMsg .= "--- Phone"; } else if(!$creditcard){ $errorMsg .= "--- Credit Card"; } else if(!$expiry){ $errorMsg .= "--- Expiry"; } else if(!$CVV){ $errorMsg .= "--- CVV"; } else if(!$email){ $errorMsg .= "--- Email Address"; } } else { $id = mysql_insert_id(); $sql = mysql_query("INSERT INTO customer (firstname, lastname, address, phone, creditcard, expiry, CVV, email) VALUES('$firstname','$lastname','$address','$phone','$creditcard','$expiry','$CVV','$email' now())") or die (mysql_error()); print "<br /><br /><br /><h4>OK $firstname, Thanks for Shopping:</h4><br /> We just sent a Confirmation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox. Thank You.</font></strong><br />"; exit(); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Billing</title> <link href="../dnb2.css" rel="stylesheet" type="text/css" /> </head> <body> <?php include_once("../template_header2.php");?> <table width="600" align="center"> <tr> <td width="7%" align= "center">Billing</td> </tr> </table> <table width="600" align="center" cellpadding="5"> <form action="billing.php" method="post" enctype="multipart/form-data"> <tr> <td colspan="2"><font color="#FF0000"><?php echo "$errorMsg"; ?></font></td> </tr> <tr> <td width="163"><div align="right">First Name:</div></td> <td width="409"><input name="firstname" type="text" value="<?php echo "$firstname"; ?>" /></td> </tr> <tr> <td width="163"><div align="right">Last Name:</div></td> <td width="409"><input name="lastname" type="text" value="<?php echo "$lastname"; ?>" /></td> </tr> <tr> <td width="163"><div align="right">Address:</div></td> <td width="409"><input name="address" type="text" value="<?php echo "$address"; ?>" /></td> </tr> <tr> <tr> <td width="163"><div align="right">Phone:</div></td> <td width="409"><input name="phone" type="text" value="<?php echo "$phone"; ?>" /></td> </tr> <tr> <td><div align="right">Credit Card: </div></td> <td><input name="creditcard" type="text" value="<?php echo "$creditcard"; ?>" /></td> </tr> <tr> <td><div align="right">Expiry: </div></td> <td> <input name="expiry" type="text" value="<?php echo "$expiry"; ?>" /> </td> </tr> <tr> <td width="163"><div align="right">CVV:</div></td> <td width="409"><input name="CVV" type="text" value="<?php echo "$CVV"; ?>" /></td> </tr> <tr> <td><div align="right">Email: </div></td> <td><input name="email" type="text" value="<?php echo "$email"; ?>" /></td> </tr> <tr> <td><div align="right"></div></td> <td><input type="submit" name="Submit" value="Submit Form" /></td> </tr> </form> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 3, 2012 Share Posted April 3, 2012 You have no form element with the name of "billing". add print_r($_POST); at the top to see what you ARE submitting. Quote Link to comment Share on other sites More sharing options...
dnbhead22 Posted April 3, 2012 Author Share Posted April 3, 2012 its printing the details at the top that are supposed to go through. what do you mean i have no form element with the name billing? Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 3, 2012 Share Posted April 3, 2012 You have no form element that has the name billing. You know how all of your form elements have a name? None of them is billing. So it never enters your if() statement. you can see that in the fact that your $_POST array does not contain a value with the key of billing. Quote Link to comment Share on other sites More sharing options...
dnbhead22 Posted April 3, 2012 Author Share Posted April 3, 2012 ok. thanks for your help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.