I'm new to PHP and I'm trying to start off on the right foot by declaring register_globals = Off. The problem I am running into is that most of the tutorials are written for = On with only rudimentary =Off info.
This simple script below illustrates my problem.
<HTML>
<?php
if($submit)
{
$db = mysql_connect("localhost", "root","");
mysql_select_db("learndb",$db);
$first=$post[first];
$last=$post[last];
$nick=$post[nick];
$email=$post[email];
$salary=(int)$_post[salary];
$sql = "INSERT INTO personnel (firstname, lastname, nick, email, salary)
VALUES ('$first', '$last', '$nickname','$email','$salary')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
}
else
{
?>
<form method="post" action="input.php">
First name:<input type="Text" name="first"><br>
Last name:<input type="Text" name="last"><br>
Nick Name:<input type="Text" name="nickname"><br>
E-mail:<input type="Text" name="email"><br>
Salary:<input type="Text" name="salary"><br>
<input type="Submit"name="submit" value=" Enter information"></form>
<?
}
?>
</HTML>
I was able to declare the variables $first, $last etc. but I am getting errors because of the $submit variable is called before being defined. What is the proper syntax for defining the submit var?
Also, does anyone know of any resources (tutorials, books, etc) that deal with post PHP 4.2 implementations and/or register_globals = off?
Thanks,
Pat