Posted: Sun Mar 21, 2004 11:38 am
if your sending the vars page to page, you should use the POST method
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
if (isset($_POST["action"]))
{
if ($_POST["action"] == "submit")
{
$db = mysql_connect("localhost", "krunk_gtstat", "gtstat");
mysql_select_db("krunk_gtstat",$db);
$sql = "INSERT INTO stats (username,percent) VALUES ('$username','$percent')";
$result = mysql_query($sql);
}
}
?>
<?php
$value1=$_POST['value1'];
$value2=$_POST['value2'];
$value3=$_POST['value3'];
$value4=$_POST['value4'];
$username=$_POST['username'];
$total=(($value1 + $value2 + $value3) / $value4);
$percent=$total * 10;
?>
<form method="POST" action=="<?php echo $PHP_SELF?>">
<font size=1 face="verdana" color=#000000>
Username:<br>
<input type"text" name="username" size="20" style="font-family: Arial; font-size: 8pt; color: #000000"><br>
Games Won<br>
<input type"text" name="value1" size="20" style="font-family: Arial; font-size: 8pt; color: #000000"><br>
Games lost by someone reaching 100 mojo<br>
<input type"text" name="value2" size="20" style="font-family: Arial; font-size: 8pt; color: #000000"><br>
Games lost by zero<br>
<input type"text" name="value3" size="20" style="font-family: Arial; font-size: 8pt; color: #000000"><br>
Games played<br>
<input type"text" name="value4" size="20" style="font-family: Arial; font-size: 8pt; color: #000000"><br>
<input type="reset" value="Reset Form" name="reset" style="font-family: verdana; font-size: 8pt; color: #000000">
<input type="submit" value="Submit" name="send" style="font-family: verdana; font-size: 8pt; color: #000000">
<input type="hidden" name="action" value="submit">
</form>
</font>notice I said "should" i didnt say he "needed" too. settle downcoreycollins wrote:It really doesn't matter if he uses a get or post. One is just more secure.
Code: Select all
<?php
$value1=$_POST['value1'];
$value2=$_POST['value2'];
$value3=$_POST['value3'];
$value4=$_POST['value4'];
$username=$_POST['username'];
$total=(($value1 + $value2 + $value3) / $value4);
$percent=$total * 10;
?>Code: Select all
if (isset($_POST["action"]))
{
if ($_POST["action"] == "submit")
{
$value1=$_POST['value1'];
$value2=$_POST['value2'];
$value3=$_POST['value3'];
$value4=$_POST['value4'];
$username=$_POST['username'];
$total=(($value1 + $value2 + $value3) / $value4);
$percent=$total * 10;
$db = mysql_connect("localhost", "krunk_gtstat", "gtstat");
mysql_select_db("krunk_gtstat",$db);
$sql = "INSERT INTO stats (username,percent) VALUES ('$username','$percent')";
$result = mysql_query($sql);
}
}
?>Code: Select all
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/krunk/public_html/gtthing/gtthing3.php on line 25
Username:
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /home/krunk/public_html/gtthing/gtthing3.php on line 29
Percentage:Code: Select all
<?php
$db = mysql_connect("localhost", "krunk_gtstat", "gtstat");
mysql_select_db("krunk_gtstat",$db);
$result = mysql_query("SELECT * FROM stat",$db);
printf("Username: %s<br>\n", mysql_result($result,0,"username"));
printf("Percentage: %s<br>\n", mysql_result($result,0,"percent"));
?>
</body>