tenfoottrike Posted March 13, 2010 Share Posted March 13, 2010 ok first off im new to php just starting to get it and well i have a simple php form submit code but when it submits to the mysql database it stops a mail and mail and on do not submit to the database here is my code if($_POST['submit']{ $comname = $_POST['comname']; $fname = $_POST['fname']; $lname = $_POST['lname']; $phone = $_POST['phone']; $email = $_post['email']; $add = $_post['add']; $city = $_post['city']; $state = $_post['state']; $zip = $_post['zip']; $stuf = $_post['stuf']; $conn = @mysql_connect("localhost","user","pass") or die('Error: ' . mysql_error()); $sql = "INSERT INTO `database`.`table` (`ID`, `comname`, `fname`, `lname`, `phone`, `email`, `add`, `city`, ` state`, `zip`, `stuf`)VALUES (NULL, '$comname', '$fname', '$lname', '$phone ', '$email', '$add', '$city', '$state', '$zip', '$stuf');"; mysql_query($sql) or die('Error: ' . mysql_error()); echo "Info submited: ".$comname." ".$fname." ".$lname." ".$phone." ".$email." ".$add." ".$city." ".$state." ".$zip." ".$stuf. mysql_close(); else{ die("fourm was not filled out right"); } } ?> also how do i redirect the page after it's done Link to comment https://forums.phpfreaks.com/topic/195088-help-passing-data-to-mysql/ Share on other sites More sharing options...
Tazerenix Posted March 13, 2010 Share Posted March 13, 2010 if($_POST['submit']{ $comname = $_POST['comname']; $fname = $_POST['fname']; $lname = $_POST['lname']; $phone = $_POST['phone']; $email = $_POST['email']; $add = $_POST['add']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $stuf = $_POST['stuf']; $conn = mysql_connect("localhost","user","pass") or die('Error: ' . mysql_error()); mysql_select_db("database", $conn) or dir(mysql_error()); $sql = "INSERT INTO `table` (`ID`, `comname`, `fname`, `lname`, `phone`, `email`, `add`, `city`, ` state`, `zip`, `stuf`)VALUES (NULL, '$comname', '$fname', '$lname', '$phone ', '$email', '$add', '$city', '$state', '$zip', '$stuf');"; mysql_query($sql) or die('Error: ' . mysql_error()); echo "Info submited: ".$comname." ".$fname." ".$lname." ".$phone." ".$email." ".$add." ".$city." ".$state." ".$zip." ".$stuf. mysql_close(); } else{ die("form was not filled out right"); } } ?> should work Link to comment https://forums.phpfreaks.com/topic/195088-help-passing-data-to-mysql/#findComment-1025514 Share on other sites More sharing options...
Rifts Posted March 13, 2010 Share Posted March 13, 2010 oops posted on wrong topic sorry Link to comment https://forums.phpfreaks.com/topic/195088-help-passing-data-to-mysql/#findComment-1025536 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.