SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    little help please

    register.html
    <body>
    <form action="register.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
    <table width="410" border="0" align="center" bordercolor="#99FFFF">
    <tr align="center" valign="middle">
    <td colspan="3"> <span class="style1">User Registration</span> </td>
    </tr>
    <tr>
    <td width="156" align="left"><div align="right" class="style4">UserName</div></td>
    <td width="22">/td>
    <td width="218"><div align="left">
    <input name="username" type="text" name="username" />
    </div></td>
    </tr>
    <tr>
    <td><div align="right" class="style4">Password</div></td>
    <td>/td>
    <td><label>
    <div align="left">
    <input name="passwrod" type="password" name="passwrod" />
    </div>
    </label></td>
    </tr>
    <tr>
    <td><div align="right" class="style4">E mail</div></td>
    <td>/td>
    <td><label>
    <div align="left">
    <input type="text" name="email" />
    </div>
    </label></td>
    </tr>
    <tr>
    <td><div align="right" class="style4">Address</div></td>
    <td>/td>
    <td><label>
    <div align="left">
    <textarea name="address"></textarea>
    </div>
    </label></td>
    </tr>
    <tr>
    <td><div align="right" class="style4">Country</div></td>
    <td>/td>
    <td><label>
    <div align="left">
    <select name="country">
    <option>india</option>
    <option>usa</option>
    <option>pak</option>
    <option>england</option>
    <option>aus</option>
    <option>newzeland</option>
    <option>rsa</option>
    <option>srilanka</option>
    <option>west indies</option>
    </select>
    </div>
    </label></td>
    </tr>
    <tr>
    <td><div align="right" class="style4">City/Area</div></td>
    <td>/td>
    <td><label>
    <div align="left">
    <select name="area" size="1" multiple="multiple" id="area">
    </select>
    </div>
    </label></td>
    </tr>
    <tr>
    <td><div align="right" class="style4">Pin Code </div></td>
    <td>/td>
    <td><label>
    <div align="left">
    <input name="pin" type="text" id="pin" />
    </div>
    </label></td>
    </tr>
    <tr>
    <td><div align="right" class="style4">Phone Number </div></td>
    <td>/td>
    <td><label>
    <div align="left">
    <input name="counrtycode" type="text" id="counrtycode" size="3" maxlength="3" />
    <input name="phoneno" type="text" id="phoneno" />
    </div>
    </label></td>
    </tr>
    <tr>
    <td><div align="left" class="style4">
    <div align="right">Upload Your Photo </div>
    </div></td>
    <td><div align="left">/div></td>
    <td><label>

    <div align="left">
    <input type="file" name="file" />
    </div>
    </label></td>
    </tr>
    <tr>
    <td colspan="3"><label>
    <div align="center">
    <input type="submit" name="Submit" value="Submit" />
    </div>
    </label></td>
    </tr>
    </table>
    </form>
    </body>

    register.php

    <?php
    $con=mysql_connect("localhost","root","");
    mysql_select_db("user",$con);
    $username = $_post[username];
    $password = $_post[password];
    $email = $_post[email];
    $add = $_post[address];
    $contry=$_post[country];
    $area=$_post[area];
    $pin=$_post[pin];
    $countrycode=$_post[countrycode];
    $phoneno=$_post[phoneno];
    $file=$_post[file];
    $qry="INSERT INTO user1 (username,password,email,address,country,area,pincode,countrycode,phoneno,file) VALUES ('$username','$password','$email','$add','$contry','$area','$pin','$countrycode','$phoneno','$file')";
    mysql_query($qry,$con);
    mysql_close($con);
    ?>
    the following errors occured.how to fix these bugs.
    Notice: Use of undefined constant username - assumed 'username' in c:\easyphp1-8\www\register.php on line 10

    Notice: Undefined variable: _post in c:\easyphp1-8\www\register.php on line 10

    Notice: Use of undefined constant password - assumed 'password' in c:\easyphp1-8\www\register.php on line 11

    Notice: Undefined variable: _post in c:\easyphp1-8\www\register.php on line 11

    Notice: Use of undefined constant email - assumed 'email' in c:\easyphp1-8\www\register.php on line 12

    Notice: Undefined variable: _post in c:\easyphp1-8\www\register.php on line 12

    Notice: Use of undefined constant address - assumed 'address' in c:\easyphp1-8\www\register.php on line 13

    Notice: Undefined variable: _post in c:\easyphp1-8\www\register.php on line 13

    Notice: Use of undefined constant country - assumed 'country' in c:\easyphp1-8\www\register.php on line 14

    Notice: Undefined variable: _post in c:\easyphp1-8\www\register.php on line 14

    Notice: Use of undefined constant area - assumed 'area' in c:\easyphp1-8\www\register.php on line 15

    Notice: Undefined variable: _post in c:\easyphp1-8\www\register.php on line 15

    Notice: Use of undefined constant pin - assumed 'pin' in c:\easyphp1-8\www\register.php on line 16

    Notice: Undefined variable: _post in c:\easyphp1-8\www\register.php on line 16

    Notice: Use of undefined constant countrycode - assumed 'countrycode' in c:\easyphp1-8\www\register.php on line 17

    Notice: Undefined variable: _post in c:\easyphp1-8\www\register.php on line 17

    Notice: Use of undefined constant phoneno - assumed 'phoneno' in c:\easyphp1-8\www\register.php on line 18

    Notice: Undefined variable: _post in c:\easyphp1-8\www\register.php on line 18

    Notice: Use of undefined constant file - assumed 'file' in c:\easyphp1-8\www\register.php on line 19

    Notice: Undefined variable: _post in c:\easyphp1-8\www\register.php on line 19

  2. #2
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is your php above your html as it should be? An undefined variable means just that - you are trying to use it before its defined.

    Please paste html inside [ code ] [ /code ] tags, and php inside [ php ] [ /php ] tags, without the extra spaces so its easier to read.

    There is no need to call mysql_close as the connection will die at the end of the script.

    Also, you need to consider validation on your form values before adding to database to prevent nasty things.
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development

  3. #3
    SitePoint Zealot Bill Palmer's Avatar
    Join Date
    Oct 2005
    Location
    London, UK
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your code:

    PHP Code:
    $username $_post[username]; 
    You need to wrap the index of the array in quotes, e.g.:

    PHP Code:
    $username $_post['username']; 
    Repeat for each line referencing $_post.

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i modified this register.php into
    PHP Code:
    PHP Code:
    <?php
    $con
    =mysql_connect("localhost","root","");
    mysql_select_db("user",$con);
      
    $username mysql_real_escape_string($_POST['username']);
      
    $password mysql_real_escape_string($_POST['password']);
      
    $email mysql_real_escape_string($_POST['email']);
      
    $add mysql_real_escape_string($_POST['address']);
      
    $contry=mysql_real_escape_string($_POST['country']);
      
    $area=mysql_real_escape_string($_POST['area']);
      
    $pin=mysql_real_escape_string($_POST['pin']);
      
    $countrycode=mysql_real_escape_string($_POST['countrycode']);
      
    $phoneno=mysql_real_escape_string($_POST['phoneno']);
      
    $file=mysql_real_escape_string($_POST['file']);
      
    $qry="INSERT INTO user1 (username,password,email,address,country,area,pincode,countrycode,phoneno,file) VALUES ('$username','$password','$email','$add','$contry','$area','$pin','$countrycode','$phoneno','$file')";
      
    mysql_query($qry,$con);
      
    mysql_close($con);
      
    ?>
    again i am getting following errors:

    Notice: Undefined index: password in c:\easyphp1-8\www\register.php on line 11

    Notice: Undefined index: area in c:\easyphp1-8\www\register.php on line 15

    Notice: Undefined index: file in c:\easyphp1-8\www\register.php on line 19

  5. #5
    SitePoint Zealot Bill Palmer's Avatar
    Join Date
    Oct 2005
    Location
    London, UK
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could have just done:

    PHP Code:
    $_post array_map('mysql_real_escape_string'$_post); 


    ----

    The notices mean that the data is not being POSTed to register.php properly.

    Add this to the top of register.php to see what is actually being passed to the script when it is run:

    PHP Code:
    echo "<pre>"# preserves formatting for print_r
    print_r($_post);
    echo 
    "</pre>"

  6. #6
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    also for password you have spelt it wrong and named it twice
    Code:
    <input name="passwrod" type="password" name="passwrod" />
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

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