leeex Posted January 10, 2010 Share Posted January 10, 2010 I'm just testing stuff out with a simple 2 input form. Everytime I submit, the data is sent (i.e. another bar in the structure for every new input) but there's no text under the values. Since I'm new at PHP, i'm still learning about setting up the sql databases. Would anyone know how I should set the values for the database? Here's my files: index.php <?php include("layout.php"); ?> <a href="/main_login.php">Login</a> <html><body> <h4>Tizag Art Supply Order Form</h4> <form action="process.php" method="post"> <input type="text" name="item"> Quantity: <input name="quantity" type="text" /> <input type="submit" /> </form> </body></html> <?php include("layout2.php"); ?> process.php <?php include("layout.php"); ?> <html><body> <?php $con = mysql_connect("localhost","root","junior"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test", $con); $name=mysql_real_escape_string($_POST['item']); $email=mysql_real_escape_string($_POST['quantity']); $sql="INSERT INTO form_data (item,quantity) VALUES ('$item','$quantity')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "The form data was successfully added to your database."; mysql_close($con); ?> </body></html> <?php include("layout2.php"); ?> Heres what my database looks like: Quote Link to comment https://forums.phpfreaks.com/topic/187967-data-doesnt-show-up-in-the-database/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 10, 2010 Share Posted January 10, 2010 The variable names you are using in your php code don't match up. You should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php will help you by displaying all the errors it detects. There would be some undefined variable messages that would help point out the mixed up variable names in your code. Quote Link to comment https://forums.phpfreaks.com/topic/187967-data-doesnt-show-up-in-the-database/#findComment-992411 Share on other sites More sharing options...
leeex Posted January 10, 2010 Author Share Posted January 10, 2010 I can't believe I didnt see that! It's working now And I'll try setting it to that. Quote Link to comment https://forums.phpfreaks.com/topic/187967-data-doesnt-show-up-in-the-database/#findComment-992422 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.