how do i prevent my php code from running until the submit button is hit?
i tried using this as a simple test :
<?
$submit = "submit"; --this is the name of my submit button
if ($submit) {
$msg = "starting";
}
?>
however this did not work.
I'm trying to check the database to see if a username already exists without have to send the user back from another page.
this is my code for checking the the db:
<?
if ($submit) {
$db_name = "******";
$table_name = "******";
$connection = @mysql_connect("***", "", "***") or die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql = "select from ***** where username ='$username'";
$result = @($sql,$connection) or die("Couldn't execute query 1.");
if (mysql_num_rows($result) > 0) {
$msg = "Name exists.";
}
}
Any help would be great.