Jump to content

Mysql W/ Php


Recommended Posts

I'm trying to make a feature that adds data to a table, the code is:

<div style="border:1px solid">ZAX Data Input:<br />Name: <input type="text" name="ZAXName" /> ID: <input type="text" name="ZAXid" /> <br />Content:<br /><textarea name="ZAXContent" rows="10" col="20" /><br /></textarea><input type="submit" name="ZAXBtn" /><br /><?php if ($_POST['ZAXBtn']) {$ZAXID=$_POST['ZAXid'];$ZAXNAME=$_POST['ZAXName'];$ZAXCONTENT=$_POST['ZAXContent'];$sql = " INSERT INTO `a7053602_forumd`.`ZAX` (`id` ,`name` ,`content`)VALUES (\'" . $ZAXID . "\', \'" . $ZAXNAME . "\', \'" . $ZAXCONTENT . "\') ";if (!mysql_query($sql,$con)) {die('Error! ' . mysql_error());}echo "Data added.";?></div>

Note: the input tags, submit button, and textarea are wrapped in <form> tags from earlier in the page. But, if it matters, which I feel that it does for some reason, it is the same <form> tags I used to wrap around a login feature to access this feature.Anywho, for the problem.I get redirected to my login portion and no data is added. I got the SQL portion (and modified it some bits by myself) from PhpMyAdmin after seeing if I can Insert data into the table. Any help?

Link to comment
Share on other sites

Er, I think the problem is my technique for Inserting the data.I'm using the same premise on another page, this:

$name = $_POST['title'];$content = $_POST['content'];if ($_POST['Douser']) {$sql = "INSERT INTO `a8949742_sm`.`Kestral` (`id` ,`name` ,`content`)VALUES (NULL , '$name', '$content')";if (!$sql) {	die('Invalid query: ' . mysql_error());}else{mysql_query($sql);}

The form tag's action is pointing towards the page it is on. For something like this, should I make a new page with this code that is pointed to by the form?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...