PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?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='registrationbutton' 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.
Last edited by RossBryan on Thu Aug 25, 2011 3:17 am, edited 1 time in total.
Any value from the $_POST array can be accessed by using the name attribute of the specific field you want to retrieve. You already have that figured out but you used the incorrect value when attempting to use isset() to see if the button has been clicked.
That hasnt worked. I didnt want to post the whole code because i didnt want to clog up the post, but have edited it with it anyway now; maybe that will help.
Yes, I changed the value of the registerbutton post button to match according to with what is used in the if statement, thanks for that. But I'm still getting an undefined notice for '$user' when I call on it.
<?php
if ($user == "Username")
$user = "";
if ($email == "Email")
$email = "";
if ($user && $email && $password)//ensures these three values are submitted
{
if (strstr ($email, "@")&& strstr($email, "."))
?>
The problem might be in your subsequent code.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering