Been about a year since i played around with websites. My database is not being updated, and after submitting form it goes to the location of the action rather than running the action. Could someone please help! I am working in wordpress. Thanks
the php form is
<?php
$con = mysql_connect("localhost","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("", $con);
$username = mysql_real_escape_string($_POST['username']);
$betText = mysql_real_escape_string($_POST['betText']);
$betMember1 = mysql_real_escape_string($_POST['betMember1']);
//$sql adds bet to bet table
$sql = "INSERT INTO betText (bettor, betText)
VALUES
('$username', '$betText')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
$newBetID = mysql_insert_id();
$updatebetMember = "INSERT INTO betMember (betID, betMember)
VALUES
('$newBetID','$betMember1')";
if (!mysql_query($updatebetMember,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con);
header("Location:")
?>
the form is
<head>
<script type="text/javascript">
function validateForm()
{
var x=document.forms["newbet"]["betText"].value
if (x==null || x=="")
{
alert("You gotta have bet!");
return false;
}
var x=document.forms["newbet"]["betMember1"].value
if (x==null || x=="")
{
alert("Who you betting against?");
return false;
}
}
</script>
</head>
<form name="newbet" action="/wp-content/pbbbet.php" onsubmit="return validateForm()" method="post">
<label for="username"><strong>Username: </strong></label>
<input id="username" name="username" type="text" readonly="readonly" value="<?php
global $current_user;
get_currentuserinfo();
echo $current_user->user_login;
?>"/>
<strong>Peanut Butter Bet: <textarea cols="50" rows="4" name="betText"></textarea>
<table width="75%" border="4">
<tr> <strong>Who is your bet against: </strong> </tr>
<tr> <th> 1. </th> <th> <input name="betMember1" type="text" /> </th> </tr>
</table>
<script type="text/javascript">
function show_alert()
{
alert("Thank you!");
}
</script>
<input name="submitbet" input type="SUBMIT" onclick="show_alert()" value="SUBMIT" />
</form>