hey guys, i have recently created a form to post into mysql table, which works perfectly! until today, someone entered blank fields and still got posted to mysql table. i am now considering entering some error checking, but thing is i dont have a clue where to start lol
here is my form:
and here is my process:Code:<form method="post" action="addscoutprocess.php"> <div align="center"> <p>Co-ordinates:<br> <input type="text" name="x" maxlength=3 size=2> <input type="text" name="y" maxlength=3 size=2> <br> Lord Name:<br><font size='2'>(type NPC if scouting a NPC)</font><br> <input type="text" name="lordname"> <br> Alliance:<br> <input type="text" name="alliance"> <br> XML URL:<br><font size='2'>(can be found at bottom of evony scout report)</font><br> <input type="text" name="xmlurl" maxlength=150> </p> <p> <input type="submit" name="Submit" value="Submit"> </p> </div> </form>
Ideally, i NEED Coordinates (x and y), lordname and xmlurlPHP Code:<?php
if (isset($_REQUEST['Submit'])) {
# THIS CODE TELL MYSQL TO INSERT THE DATA FROM THE FORM INTO YOUR MYSQL TABLE
$sql = "INSERT INTO $db_table(x,y,lordname,alliance,xmlurl) values ('".mysql_real_escape_string(stripslashes($_REQUEST['x']))."','".mysql_real_escape_string(stripslashes($_REQUEST['y']))."','".mysql_real_escape_string(stripslashes($_REQUEST['lordname']))."','".mysql_real_escape_string(stripslashes($_REQUEST['alliance']))."','".mysql_real_escape_string(stripslashes($_REQUEST['xmlurl']))."')";
if($result = mysql_query($sql ,$db)) {
echo '<h1>Thank you</h1>Your Scout Report has been added successfully!<br><br>';
echo "[<a href='addscout.php'>Add Another Scout Report</a>] [<a href='viewscout.php'>View Scout Reports</a>]";
} else {
echo "ERROR: ".mysql_error();
}
} else {
?>
<form method="post" action="addscoutprocess.php">
<div align="center">
<p>Co-ordinates:<br>
<input type="text" name="x" maxlength=3 size=2> <input type="text" name="y" maxlength=3 size=2>
<br>
Lord Name:<br><font size='1'>(type NPC if scouting a NPC)</font><br>
<input type="text" name="lordname">
<br>
Alliance:<br>
<input type="text" name="alliance">
<br>
XML URL:<br><font size='1'>(can be found at bottom of evony scout report)</font><br>
<input type="text" name="xmlurl" maxlength=150>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</div>
</form>
<div align="center">
<?php
}
?>
i would be grateful if anyone could help, thanx!



Reply With Quote

Bookmarks