Jump to content

Sending to MySQL via Form help >_<


mtesm

Recommended Posts

Well im trying to make it so users input strings into a form and it sends it and the time and their username they're logged in as to mySQL database and i keep getting the same error which is confusing because i cant see the problem >_<

 

<h1>Submit Data</h1>
<?php
//include("include/session.php");

if($session->logged_in){
  echo "<form name='submitdata' methord='post' action='submit.php'>";
  echo "World: <br> <input type='text' name='world'/><br>";
  echo "Category:<br><input type='text' name='category'/><br>";
  echo "Name:<br> <input type='text' name='name'/><br>";
  echo "Price:<br><input type='text' name='price'/><br>";
  echo "<input type='submit' value='Submit Data' />";
  echo "</form>";
if (isset ($_POST['name'])) {
$price = $_POST['price'];
$name = $_POST['name'];
$category = $_POST['category'];
$world = $_POST['world'];
$time_now = date('mdy');
$human_now = date('l jS \of F Y h:i:s A');
//Lets connect to the database
$connection = mysql_connect ("localhost","x","x") or die ("Cannot connect to db");
//then select the database that we are using.
mysql_select_db("price_list",$connection);

//now the SQL INSERT     [ These are the table names]     [and here are the values going into those tables]
$SQL = "INSERT into item (time,world,category,name,price)	VALUES ('".$time_now."','".$world."','".$category."',,'".$name."',,'".$price."')";

// Send our SQL
$result = mysql_query($SQL,$connection) or die (mysql_error());
echo "DATA SENT<br>";
echo "=========<br>";
echo $time_now. "<br>";
echo $human_now. "<br>";
echo $session->username. "<br>";
echo $world. "<br>";
echo $category. "<br>";
echo $name. "<br>";
echo $price. "<br>";
}
}
else{
  echo "Hello <b>$session->username</b>, this is a page where users can submit data, so we please <a href=\"account.php\">login</a> to view this page. Not registered? <a href=\"register.php\">Sign-Up</a>";
}
?>

the session.php is included on the page that includes this into it. and this is included in submit.php

Link to comment
https://forums.phpfreaks.com/topic/131286-sending-to-mysql-via-form-help-_/
Share on other sites

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.