Jump to content

Data doesnt show up in the database?


leeex

Recommended Posts

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.

XWSCB.png

 

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:

kiDXN.png

 

Link to comment
https://forums.phpfreaks.com/topic/187967-data-doesnt-show-up-in-the-database/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.