Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts

    HELP!!! Defining variables with form values

    How would i go about correctly defining the following variables that i am taking in from a form.

    PHP Code:
    <?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.
    Last edited by RossBryan; 08-25-2011 at 10:26 AM.

  • #2
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    PHP Code:
    if(isset($_POST['user'])) {

       
    // do this




  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •