Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,664 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,170 people online right now. Registration is fast and FREE... Join Now!




Registration form problem

 
Reply to this topicStart new topic

Registration form problem

antiturncoat
post 9 Aug, 2007 - 12:26 AM
Post #1


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


here's the error
Parse error: parse error, unexpected T_EMPTY in c:\phpdev5\www\softlandia\register.php on line 27

CODE


<?php
ob_start();
include 'includes/connect.php';

if(isset($_POST['register'])){
    
      //$date = date("Y-m-d");
      $firstname=$_POST['firstname'];
      $middlename=$_POST['middlename'];
      $lastname=$_POST['lastname'];
      $month=$_POST['month'];
      $day=$_POST['date'];
      $year=$_POST['year'];
      $gender=$_POST['gender'];
      $address=$_POST['address'];
      $city=$_POST['city'];
      $username=$_POST['username'];
      $password=$_POST['password'];
      $cpassword=$_POST['cpassword'];
      $email=$_POST['email'];
      $cemail=$_POST['cemail'];
      $question=$_POST['question'];
      $answer=$_POST['answer'];
    
      
      
      if(empty($username)||empty($password)||empty($cpassword)||empty($email)||empty($cemail)empty($firstname)||empty($middlename)||empty($lastname)||empty($month)||empty($date)||empty($year)||empty($gender)||empty($address)||empty($city)||empty($question)||empty($answer))
       {
         $Problem=true;
         $errors="<li><b>empty field(s)</b></li>";
       }

       if(strcmp($password,$cpassword)!=0)
       {
         $Problem=true;
         $errors="<li><b>password and confrim password does not match!<br></b></li>";
       }


      $queryad="Select username from admin where username='$username'";
      $resultad=mysql_query($queryad);

      if(mysql_num_rows($resultad)!=0)
      {
         $Problem=true;

                  $errors="<li><b>reserved username!<b></li>";
        }


    if(!$Problem){

        $query="Select username from accounts where username='$username'";
        $result=mysql_query($query);


        if(mysql_num_rows($result)!=0)
        {
        $errors="<li><b>username already exist!<b></li>";
        }
        else
        {
        //add comment successfully registered

        mysql_select_db('Softlandia') or die(mysql_error());
        mysql_query("Insert into members& #40;dateregister,username,firstname,middlename,lastname,month,date,year,gender,a
ddress,city,question,answer,email) values('$username','$firstname','$middlename','$lastname','$month','$date','$year','$gender','$address','$city','$question','$answer,'$email','$date')");
        mysql_query("Insert into accounts(username,password) values('$username','$password')");
        header('Location: Customer.php');
          }
        }

    }

?>








This post has been edited by antiturncoat: 9 Aug, 2007 - 12:27 AM
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 9 Aug, 2007 - 01:42 AM
Post #2


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


I believe I might have found your problem, Ill mark it in the line I found it

(no || between empty($cemail)empty($firstname))

CODE

if(empty($username)||empty($password)||empty($cpassword)||empty($email)||empty($cemail)empty($firstname)||empty($middlename)||empty($lastname)||empty($month)||empty($date)||empty($year)||empty($gender)||empty($address)||empty($city)||empty($question)||empty($answer))
                                                                                       ^ no || here
User is offlineProfile CardPM

Go to the top of the page

antiturncoat
post 9 Aug, 2007 - 03:51 AM
Post #3


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


Good day i'm really having a hard time in getting the correct output..
heres what i wanted to do
* display the time
* retain the values inside the textfields if an error occured except for the password,cpassword and email and confirm email if the error is in the email part
*prompt an error if the username is equal to admin
*check the availability of the username if the check availability button is click
Thanks Guys and God Bless!!
CODE


<?php
ob_start();
include 'includes/connect.php';


   //$date = date("Y-m-d");
   $username=$_POST['username'];
   $password=$_POST['password'];
   $cpassword=$_POST['cpassword'];
   $email=$_POST['email'];
   $cemail=$_POST['cemail'];
   $firstname=$_POST['firstname'];
   $middlename=$_POST['middlename'];
   $lastname=$_POST['lastname'];
   $month=$_POST['month'];
   $date=$_POST['date'];
   $year=$_POST['year'];
   $gender=$_POST['gender'];
   $address=$_POST['address'];
   $city=$_POST['city'];
   $question=$_POST['question'];
   $answer=$_POST['answer'];
    
   if(isset($_POST['register'])){
      if(empty($username)||empty($password)||empty($cpassword)||empty($email)||empty($cemail)||empty($firstname)||empty($middlename)||empty($lastname)||empty($month)||empty($date)||empty($year)||empty($gender)||empty($address)||empty($city)||empty($question)||empty($answer)){
         $Problem=true;
         $errors="<li><b>empty field(s)</b></li>";
      }

      if(strcmp($password,$cpassword)!=0){
         $Problem=true;
         $errors="<li><b>password and confrim password does not match!<br></b></li>";
      }

      if(!$Problem){
         $query="Select username from accounts where username='$username'";
         $result=mysql_query($query);
    
         if(mysql_num_rows($result)!=0){
            $errors="<li><b>username already exist!<b></li>";
         }
         else{
            //add comment successfully registered
            mysql_select_db('Softlandia') or die(mysql_error());
            mysql_query("Insert into members& #40;username,firstname,middlename,lastname,month,date,year,gender,address,city,q
uestion,answer,email) values('$username','$firstname','$middlename','$lastname','$month','$date','$year','$gender','$address','$city','$question','$answer,'$email','$date')");
            mysql_query("Insert into accounts(username,password) values('$username','$password')");
            header('Location: Customer.php');
        }
     }
   }

?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Register</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div align="center">
  <p><img src="images/Header.jpg" width="498" height="93">
  </p>
  <p><img src="images/Header2.JPG" width="198" height="25"></p>
  <div align="left">
    <table width="128%" border="0">
      <tr>
        <td width="43%" height="102"><table width="93%" border="3" bordercolor="#0000FF" bgcolor="#99FF00">
            <tr>
              <td><div align="center"><font color="#0000FF"><a href = "Main.php">Home</a></font></div></td>
              <td><div align="center"><a href="Login.php">Login</a> </div></td>
              <td><div align="center"><font color="#0000FF">Register</font></div></td>
              <td><div align="center"><font color="#0033FF"><a href="Softwares.php">Softwares</a></font></div></td>
              <td><div align="center"><font color="#0000CC">About Us</font></div></td>
            </tr>
          </table></td>
        <td width="57%"><p> </p>
          <p align="right"><strong>Search</strong>
            <input type="text" name="textfield">
            <select name="select">
              <option>[Select]</option>
              <option>Antivirus, Firewall, Spyware</option>
              <option>Audio Softwares</option>
              <option>Business Softwares</option>
              <option>Developer Softwares</option>
              <option>Video Softwares</option>
            </select>
            <img src="images/Go.gif" width="32" height="20"> </p>
          <p> </p></td>
      </tr>
    </table>
    <table width="131%" height="2373" border="0">
      <tr>
        <td width="21%" height="2332" valign="top"> <div align="left">
            <table width="84%" height="189" border="0">
              <tr>
                <td><div align="center">Antivirus, Firewall, Spyware</div></td>
              </tr>
              <tr>
                <td><div align="center">Audio Softwares</div></td>
              </tr>
              <tr>
                <td><div align="center">Business Softwares</div></td>
              </tr>
              <tr>
                <td><div align="center">Developer Softwares</div></td>
              </tr>
              <tr>
                <td><div align="center">Video Softwares</div></td>
              </tr>
            </table>
          <p> </p></div></td>
        <td width="52%" valign="top" bordercolor="#000033" bgcolor="#FFFFFF"> <div align="justify">
            <p> <?php echo getdate()?></p>
            <form method="POST" action="Register.php">
            <p>   <strong>Softlandia User System > Register</strong></p>
            <p align="center"> <?php echo "$errors" ?></p>
            <p><strong>      </strong><font color="#CC0000"><strong>
              Account Settings:</strong></font></p>
            <p>      <strong>  Username </strong>    
                          
              <input name="username" type="text" id="username" maxlength="10">
              <font color="#FF0000">*   </font>  
              <input name="check" type="submit" id="check7" value="Check Availability">
              <br>
                                  
                                
                 6-10 characters only, No<br>
                                  
                                
                 spaces and special characters. </p>
            <p>       <strong>  Password</strong>  
                              
              <input name="password" type="password" id="password" maxlength="10">
              <font color="#FF0000">*   </font>  <br>
                                  
                                
                Minimum of 6 characters, No<br>
                                  
                                
                spaces and special characters. </p>
            <p><strong>         <strong> Confirm Password</strong>
                
              <input name="cpassword" type="password" id="cpassword">
              <font color="#FF0000">*   </font>  <br>
                                  
                                
               </strong></p>
            <p>        <strong> Email Address</strong>
                      
              <input name="email" type="text" id="email">
              <font color="#FF0000">*   </font>  <br>
                                  
                                
              <strong> Important:</strong> Please enter a VALID email address</p>
            <p>        <strong>Confirm Email Addres</strong>  
              <input name="cemail" type="text" id="cemail">
              <font color="#FF0000">*   </font>  <br>
            </p>
            <p><strong>     </strong><font color="#CC0000"><strong>
              Personal Information:</strong></font></p>
            <p>        <strong> First Name</strong>  
                              
              <input name="firstname" type="text" id="firstname">
              <font color="#FF0000">*   </font>  </p>
            <p>       <strong>  Middle Name</strong>  
                          
              <input name="middlename" type="text" id="middlename">
              <font color="#FF0000">*   </font>  </p>
            <p>      <strong>  Last Name </strong>  
                              
              <input name="lastname" type="text" id="lastname">
              <font color="#FF0000">* </font></p>
            <p>      <strong>  Birthdate</strong>    
                              
              <select name="month" id="month">
                <option>[Select Month]</option>
                <option>January</option>
                <option>February</option>
                <option>March</option>
                <option>April</option>
                <option>May</option>
                <option>June</option>
                <option>July</option>
                <option>August</option>
                <option>September</option>
                <option>October</option>
                <option>November</option>
                <option>December</option>
              </select>
              <font color="#FF0000">
              <input name="date" type="text" id="date" size="2" maxlength="2">
              <input name="year" type="text" id="year" size="4" maxlength="4">
              * </font></p>
            <p>      <strong>  Gender </strong>    
                                  
              <select name="gender" id="gender">
                <option>[Select]</option>
                <option>Male</option>
                <option>Female</option>
              </select>
              <font color="#FF0000">* </font></p>
              <p>       <strong>  Address</strong>  
                                    
                <font color="#FF0000">
                <input name="address" type="text" id="address" size="30">
              * </font></p>
            <p>      <strong>  City</strong>    
                                <font color="#FF0000">
                    
              <select name="city" id="city">
                <option>[Select]</option>
                <option>Quezon City</option>
                <option>Manila</option>
                <option>Caloocoan City</option>
                <option>Davao City</option>
                <option>Cebu City</option>
                <option>Zamboanga City</option>
                <option>Pasig City</option>
                <option>Valenzuela City</option>
                <option>Las Pinas City</option>
                <option>Antipolo City</option>
                <option>Taguig City</option>
                <option>Cagayan De Oro City</option>
              </select>
              * </font></p>
            <p><strong>     </strong><font color="#CC0000"><strong>
              Secret Question: </strong></font></p>
            <p>      <strong>  Security Question</strong>
                  
              <select name="question" id="question">
                <option selected>[Select a question]</option>
                <option>What is your father's middle name</option>
                <option>What was the name of your first school</option>
                <option>Who was your childhood hero</option>
                <option>What is your pet's name</option>
              </select>
              <font color="#FF0000">*</font></p>
            <p>      <strong>  Your Answer</strong>  
                        
              <input name="answer" type="text" id="answer">
              <font color="#FF0000">*   </font>  <br>
                                  
                                
              . </p>
            <p><strong>     </strong><font color="#CC0000"><strong>
              


This post has been edited by hotsnoj: 9 Aug, 2007 - 06:32 AM
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 9 Aug, 2007 - 03:56 AM
Post #4


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


Well the easiest way to accomplish #2 is through client side validation (JavaScript), that way the data is validated client side and any errors are found before getting to the server (meaning no round-trips to the server carrying data back and forth).

How are you wanting to display the time?
User is offlineProfile CardPM

Go to the top of the page

antiturncoat
post 9 Aug, 2007 - 04:08 AM
Post #5


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


oops i forgot to get the yahoo terms!! hehehehe

can you show me how to use this codes..
im really having a hard time

bout the time i wanted to display the time in all pages just like what you did below can you show me how to do it
thanks again
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 9 Aug, 2007 - 04:11 AM
Post #6


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


What are you doing with Yahoo's TOS text? Are you planning on using it in your site, without permission? Not a good idea man. Next, put all that code in [ code ] blocks, its making this page HUGE and I have to scroll horizontally to get to the other side, not good. As far as JavaScript form validation, use Google for that. I'm not going to do all the work for you smile.gif
User is offlineProfile CardPM

Go to the top of the page

antiturncoat
post 9 Aug, 2007 - 04:21 AM
Post #7


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


nope just a sample so that i could see the output..
lastly can you edit my post and remove the terms and licenses to avoid any trouble...

Thanks for the help..
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 9 Aug, 2007 - 04:24 AM
Post #8


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


QUOTE(antiturncoat @ 9 Aug, 2007 - 05:21 AM) *

nope just a sample so that i could see the output..
lastly can you edit my post and remove the terms and licenses to avoid any trouble...

Thanks for the help..


I dont have access to do this, you'll need to do it yourself (put the stuff in [ code ] tags as well. See screenshot below


Attached Image
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 05:46AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month