Sorry to the pros cause I know you get this a lot but I really can't figure this out. I have tried and tried and tried but it seems like lately I can't get any server code to work. Even if it's worked in the past with the same code.
THIS IS THE PAGE THAT WONT UPDATE:
<html>
<head>
<title>Gus' Private Site</title>
<script language="javascript" src="eraseIt.js"></script>
<script type="text/javascript">
function CheckInfo()
{
var x=document.getElementById("user").value;
var y=document.getElementById("pass").value;
if (x<="" || y<="")
{
document.getElementById("txt1").innerHTML="Form not complete.";
}
else if (x>"" && y>"")
{
document.getElementById("txt1").innerHTML="";
document.getElementById("b1").type="submit";
document.getElementById("b1").click();
}
}
</script>
</head>
<body onload="eraseText()">
<h3>Welcome to my private website for friends and family. <br>
It is finally up and running.</h3>
<form name="yourInfo" target="_self" action="index.php" method="$_POST">
<div id="txt1"></div><br>
Sign in <br>
Username: <input id="user" type="text" name="uName" onkeydown="if (event.keyCode == 13) document.getElementById('b1').click()"><br> <!-- uName: userName -->
Password: <input id="pass" type="password" name="pWord" onkeydown="if (event.keyCode == 13) document.getElementById('b1').click()">
<input id="b1" type="button" value="Login" onclick="CheckInfo()">
</form> <br>
<?php
$con = mysql_connect("localhost","root","panda31193");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
error_reporting(0);
mysql_select_db("my_private_site", $con);
$UaP1 = mysql_query("SELECT * FROM signinfo WHERE FirstName='Augustus'");
$UaP2 = mysql_query("SELECT * FROM signinfo WHERE FirstName='Bianca'");
$loginfo1 = mysql_query("SELECT * FROM loginfo WHERE FirstName='Augustus'");
$user = $_REQUEST["uName"];
$pass = $_REQUEST["pWord"];
$true = "true";
$false = "false";
$log1 = mysql_fetch_array($loginfo1); //Augustus
$row1 = mysql_fetch_array($UaP1); //Augustus
$row2 = mysql_fetch_array($UaP2); //Bianca
if ($user==$row1['Username'] && $pass==$row1['Password']) //Augustus
{
mysql_query("UPDATE loginfo SET On='$true' WHERE FirstName='Augustus'");
echo "<script type=\"text/javascript\">document.location.href=\"main_1.php\";</script>";
}
else if ($user==$row2['Username'] && $pass==$row2['Password']) //Bianca
{
echo "<script type=\"text/javascript\">document.location.href=\"main_2.php\";</script>";
}
else
{
null;
}
mysql_close($con);
?>
</body>
</html>
AND THIS IS THE PAGE THAT WONT LET ME INSERT:
<html>
<head>
<script type="text/javascript">
function toAlex()
{
document.getElementById("T1").value="Alex";
}
function toGus()
{
document.getElementById("T1").value="Gus";
}
function fromAlex()
{
document.getElementById("T2").value="Alex";
}
function fromGus()
{
document.getElementById("T2").value="Gus";
}
function sendMessage()
{
var x=document.getElementById("T1").value;
var y=document.getElementById("T2").value;
var z=document.getElementById("Message").value;
if (x>"" && y>"" && z>"")
{
document.getElementById("B1").type="submit";
document.getElementById("B1").click();
}
else
{
document.getElementById("B1").type="button";
document.getElementById("txt1").innerHTML="Form not complete.";
null;
}
}
</script>
</head>
<body>
<div style="position:absolute; top:26px; left:5px">To: </div> <div style="position:absolute; top:26px; left:300px" id="txt1"></div>
<div style="position:absolute; top:71px; left:5px">From: </div> <div style="position:absolute; top:71px; left:300px" id="txt2"></div>
<div style="position:absolute; top:121px; left:5px">Message: </div> <div style="position:absolute; top:500px; left:300px" id="txt2"></div>
<form target="frame" method="_$POST" action="sendMessage.php">
<input style="position:absolute; top:25px; left:72px; width:50px" type="text" id="T1" name="T1" readonly="readonly">
<select style="position:absolute; top:26px; left:140px">
<option value="Select Contact">Select Contact</option>
<option onclick="toAlex()" value="Alex">Alex</option>
<option onclick="toGus(开发者_Python百科)" value="Gus">Gus</option>
</select>
<br>
<input style="position:absolute; top:70px; left:72px; width:50px" type="text" id="T2" name="T2" readonly="readonly">
<select style="position:absolute; top:71px; left:140px" id="T2" name="T2">
<option value="Select Contact">Select Contact</option>
<option onclick="fromAlex()" value="Alex">Alex</option>
<option onclick="fromGus()" value="Gus">Gus</option>
</select> <br> <br>
<textarea style="position:absolute; top:120px; left:72px; width:400px; height:280px" id="Message" name="Message"></textarea>
<input style="position:absolute; top:414px; left:356px" type="button" id="B1" name="B1" value="Send Message" onclick="sendMessage()">
</form>
<?php
$con = mysql_connect("localhost","root","panda31193");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
error_reporting(0);
mysql_select_db("my_private_site", $con);
$to = $_REQUEST["T1"];
$from = $_REQUEST["T2"];
$message = $_REQUEST["Message"];
mysql_query("INSERT INTO other (To,From,Text) VALUES ('$to', '$from', '$message'");
mysql_close($con);
?>
</body>
</html>
One small bracket is missing there in query
mysql_query("INSERT INTO other (To,From,Text) VALUES ('$to', '$from', '$message')");
Initial glance: Your FORM
tag's method is "$_POST"
. It should be "POST"
精彩评论