clem25
03-27-2012, 03:07 PM
I m trying to send data to my database (Mysql). When I enter things in the prompt box it doesn t go to my database.
Can someone tell me why, please?
Here is my code:
<script type="text/javascript">
function show_prompt()
{
var name=prompt("question");
if (name!=null && name!="")
{
//set the hidden input value to the value entered in the prompt
document.input.purpose.value = name; //document.input referring to the form named 'input'
document.input.submit(); //submit the form
}
}
</script>
<form id="propose" name="input" action="insertpropose.php" method="post"><br/>
<input type="submit" onclick="show_prompt()" value="propose" />
<input type="hidden" name="propose" value="">
</form>
and the insertpropose.php form is:
$propose=$_POST['propose'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO propose VALUES ('','$propose')";
mysql_query($query);
mysql_close();
Can someone tell me why, please?
Here is my code:
<script type="text/javascript">
function show_prompt()
{
var name=prompt("question");
if (name!=null && name!="")
{
//set the hidden input value to the value entered in the prompt
document.input.purpose.value = name; //document.input referring to the form named 'input'
document.input.submit(); //submit the form
}
}
</script>
<form id="propose" name="input" action="insertpropose.php" method="post"><br/>
<input type="submit" onclick="show_prompt()" value="propose" />
<input type="hidden" name="propose" value="">
</form>
and the insertpropose.php form is:
$propose=$_POST['propose'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO propose VALUES ('','$propose')";
mysql_query($query);
mysql_close();