why not instead of:
you use this code?PHP:$submit=$_POST['submit']; if($submit=="Submit"){
Makes the code simplerPHP:if($_POST['submit']=="Submit"){
Edit:
the simpler it is the less probable is for you to get an error
if (strtolower($_POST['submit'])=="submit") {...}
1) $con = mysql_connect("localhost","username","password");
2) mysql_select_db("Feedback", $con);
3) mysql_query("INSERT INTO Feedback (Name, Message)
VALUES ('$firstname', '$message')");
}
<?
$firstname=$_POST['Name'];
$message=$_POST['Message'];
$submit=$_POST['submit'];
if($submit=="Submit"){
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("databaseName", $con);
mysql_query("INSERT INTO Feedback (Name, Message)
VALUES ('$firstname', '$message')");
echo "DONE";
}
echo "$firstname";
echo "$message";
?>
<form method="post">
Firstname: <input type="text" name="Name"><br />
Message: <input type="text" name="Message"> <br />
<input type="submit" name="submit" value="Submit">
</form>
Firstname: <input type="text" name="Fname"><br />
VALUES ('${firstname}', '${message}')");
xcaliberse said:and here is the pic of the database
http://i253.photobucket.com/albums/h...berse/blah.jpg
I don't think so. In PHP it has no problem but it must be usable so there is an other option. change the '' to `` that should do the trick...
Also does anyone know if ${variable} is acceptable in PHP like it is in Perl? If so, that's how you want to call your variable when directing to the database. This (at least in Perl) makes sure you don't have to escape anything inside the variable.
So it would be something like:
but make sure that's correct PHP syntax firstPHP:VALUES ('${firstname}', '${message}')");
.
My problem is still not fixed lol, it doesnt save it in the name part.
Yep, the name field is an integer number in your setup.
Change it to VARCHAR(255), TINYTEXT or another string-type.
Have a look here for an overview of mysql datatypes: http://www.htmlite.com/mysql003.php
I don't think so. In PHP it has no problem but it must be usable so there is an other option. change the '' to `` that should do the trick
addslashes ()
VALUES ('addslashes ($firstname)', 'addslashes ($message)')");
... Can someoen tell me how to display the table?
Somebody wanna just show me how my script is supposed to look like so i can copy and paste?
Edit:
Nevermind I got it to work and umm... Can someoen tell me how to display the table?