...

View Full Version : HELP!!! Defining variables with form values



RossBryan
08-25-2011, 08:46 AM
How would i go about correctly defining the following variables that i am taking in from a form.


<?php require ("design/top.php"); ?>

<title>Care2Share - Register</title>

<div id= 'left'>

<?php
$form = "<form action='register.php' method='post'>
<table cellspacing='10px'>
<tr>
<td><input type='text' id='usernameboxReg' name='user' tabindex='1' value='Username' class='textbox' onfocus='usernameboxReg_focus();' onblur='usernameboxReg_blur();'></td>
<td><font size='-1' color='#FF0000'>(*required)</font></td>
</tr>
<tr>
<td><input type='text' id='emailbox' name='email' tabindex='2' value='Email' class='textbox' onfocus='emailbox_focus();' onblur='emailbox_blur();' /></td>
<td><font size='-1' color='#FF0000'>(*required)</font></td>
</tr>
<tr>
<td><input type='text' id='passwordboxReg' name='pass' tabindex='3' value='Password' class='textbox' onfocus='passwordboxReg_focus();' onblur='passwordboxReg_blur();' /></td>
<td><font size='-1' color='#FF0000'>(*required)</font></td>
</tr>
<tr>
<td><input type='submit' name='registerbutton' class='button' value='Register'/></td>
</tr>

</table>
</form>";

if (isset($_POST['registerbutton']))
{
$user = $_POST['user'];
$email = $_POST['email'];
$password = $_POST['pass'];

if ($user == "Username")
$user = "";
if ($email == "Email")
$email = "";

if ($user && $email && $password)//ensures these three values are submitted
{
if (strstr ($email, "@")&& strstr($email, "."))
{
require ("design/connect.php");

$query = mysql_query("SELECT * FROM users WHERE user='$user'");//select everything from the users table where everything =the username provided
$numrows = mysql_num_rows($query);//does the query say the username is taken?


}

else
echo "That is not a valid email.$form";

}
else
echo "You did not fill in the required fields.$form";

}

else
echo "$form";

?>

</div>

<?php require ("design/bottom.php"); ?>

Ive tried to apply the (isset ()) function for example: (isset($_POST=['user']))
but it doesnt seem to be defining my new variable. could anyone possible lend me some advise.

webdev1958
08-25-2011, 08:51 AM
if(isset($_POST['user'])) {

// do this

}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum