www.webdeveloper.com
Results 1 to 15 of 15

Thread: Registration Problem (SIGN UP)

  1. #1
    Join Date
    Apr 2005
    Posts
    70

    Question Registration Problem (SIGN UP)

    Please help me to figure out what is the problem with this code.I ve tried register and successful.I received the confirmation email (username & password) and i can successfully sign in to the website. But, when i tried with other mail account, i received the confirmation email but i can't sign in to the website. When i checked the database, the registration info was not insert into the database. So, i am really confused why the codes works properly only for the certain mail address and not for all mail address.

    Successfully insert to the database (eg:yahoo,gmail)
    Didn't save / insert to the database (eg:marin-dbase.com)(my other account for other domains)

    Here is the code
    PHP Code:
    <? include("../conn/conndb.inc"?>

    <?php
    $username
    =$_POST['username'];
    $sql="SELECT username FROM member WHERE username='$username'"
    $result mysql_query($sql) or die('Query failed. ' mysql_error()); 
    //jumpa username yg sama
    if (mysql_num_rows($result) == 1) {

    $salutation=$_POST['salutation'];
    $name=$_POST['name'];
    $nationality=$_POST['nationality'];
    $address=$_POST['address'];
    $postal_code=$_POST['postal_code'];
    $city=$_POST['city'];
    $state=$_POST['state'];
    $country=$_POST['country'];
    $contactNo=$_POST['contactNo'];
    $faxNo=$_POST['faxNo'];
    $email=$_POST['email'];
    $organization=$_POST['organization'];
    $website=$_POST['website'];
    $position=$_POST['position'];

    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <form name="frm" method="post" action="index.php?menu=registerMember">
    <table align="center" width="100%">
        <tr>
            <td align="center" height="150"><b>Username already exist. Choose other</b></td>
        </tr>
        <tr>
            <td>
                <input type="hidden" name="salutation" value="<?php echo $salutation?>">
                <input type="hidden" name="name" value="<?php echo $name?>">
                <input type="hidden" name="nationality" value="<?php echo $nationality?>">
                <input type="hidden" name="address" value="<?php echo $address?>">
                <input type="hidden" name="postal_code" value="<?php echo $postal_code?>">
                <input type="hidden" name="city" value="<?php echo $city?>">
                <input type="hidden" name="state" value="<?php echo $state?>">
                <input type="hidden" name="country" value="<?php echo $country?>">
                <input type="hidden" name="contactNo" value="<?php echo $contactNo?>">
                <input type="hidden" name="faxNo" value="<?php echo $faxNo?>">
                <input type="hidden" name="email" value="<?php echo $email?>">
                <input type="hidden" name="organization" value="<?php echo $organization?>">
                <input type="hidden" name="website" value="<?php echo $website?>">
                <input type="hidden" name="position" value="<?php echo $position?>">
                
            </td>
        </tr>
        <tr>
            <td align="center"><input type="submit" name="submit" value="- OK -"></td>
        </tr>
        <tr>
            <td><br><br></td>
        </tr>
    </table></form>
    </body>
    </html>
    <?//    header("Location: ../frontpage/index.php?menu=signin&action=username");
        
    exit;
    } else 
    // check username & password

    {
    //generating password
    # all the chars we want to use 
            
    $length=8;
            
    $all=explode(" "
             
    "a b c d e f g h i j k l m n o p q r s t u v w x y z " 
            
    "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z " 
            
    "0 1 2 3 4 5 6 7 8 9"); 
            for(
    $i=0;$i<$length;$i++) { 
                
    srand((double)microtime()*1000000); 
                
    $randy=rand(061); 
                
    $pass.=$all[$randy]; 
            }
        
    //print "$pass";
        //print "<br> Generating password compelete";
    //end generate password
    $salutation=$_POST['salutation'];
    $name=$_POST['name'];
    $nationality=$_POST['nationality'];
    $address=$_POST['address'];
    $postal_code=$_POST['postal_code'];
    $city=$_POST['city'];
    $state=$_POST['state'];
    $country=$_POST['country'];
    $contactNo=$_POST['contactNo'];
    $faxNo=$_POST['faxNo'];
    $email=$_POST['email'];
    $username=$_POST['username'];
    $password=$pass;
    $organization=$_POST['organization'];
    $website=$_POST['website'];
    $position=$_POST['position'];
    $status1='TRUE';
    /*mysql_select_db ("irrdb");*/
    mysql_query("INSERT INTO member (salutation, name, nationality, address, postal_code, city, state, country, contactNo, faxNo, email, username, password, organization, website, position, status)
    VALUES ('
    $salutation','$name','$nationality','$address','$postal_code','$city','$state','$country','$contactNo', '$faxNo','$email','$username','$password','$organization','$website','$position','$status1')");  

    $to $email;
    $subject "Welcome to IRRDB Website";
    $message "Congratulations! Your registration has been successful. \n";
    $message $message.''."\n";
    $message $message.''."Your username is : $username \n";
    $message $message.''."Your password is : $pass \n";
    $message $message.''."\n";
    $message $message.''."Thank you for registering with IRRDB Website";
    $from "irrdb@streamyx.com";
    $headers "From: $from";
    mail($to,$subject,$message,$headers);
    //echo "Mail Sent.";

    //mysql_close();
    ?>
    <html>
    <head>
    <meta http-equiv="Refresh" content="3;url=index.php">
    </head>
    <body>
    <table align="center">
        <tr>
            <td align="center"><b>Successfully registered. Your password will be sent to your email </b></td>
        </tr>
    </table>

    </body>
    </html>

    <?
    }
    ?>

  2. #2
    Join Date
    Mar 2010
    Posts
    2,803
    what is the mysql error that you get when the insert fails?

  3. #3
    Join Date
    Apr 2005
    Posts
    70
    I don't get any error message.it's just i can't sign in to the website (username@password incorrect).So, i checked the database and there is no data insert from the registration form.But, i receive the confirmation email that gave me the username & password..This only happened for certain mail address and not for all mail address.

    Successfully insert to the database (eg:yahoo,gmail)
    Didn't save / insert to the database (eg:marin-dbase.com)(my other account for other domains)

  4. #4
    Join Date
    Jan 2009
    Posts
    3,346
    You need to check to see if the query was a success before you send the email:
    PHP Code:
    $result mysql_query("INSERT INTO member (salutation, name, nationality, address, postal_code, city, state, country, contactNo, faxNo, email, username, password, organization, website, position, status)
    VALUES ('
    $salutation','$name','$nationality','$address','$postal_code','$city','$state','$country','$contactNo', '$faxNo','$email','$username','$password','$organization','$website','$position','$status1')");

    if(!
    $result){
      echo 
    "The insert failed: ".mysql_error();
      exit;
    }

    $to $email;
    ... 

  5. #5
    Join Date
    Apr 2005
    Posts
    70
    Dear criterion9,

    I ve tried the solution that you gave,but it did'nt send any error message.Now,i don't received any confirmation email when i used (marin-dbase.com) mail services. Before this,it just didn't insert the data into the database but i ve received a confirmation email. When i tried register this morning with other mail services(quirana. com & yahoo.com),it's working properly.(i received email and can sign in).

  6. #6
    Join Date
    Jan 2009
    Posts
    3,346
    Did it say "The insert failed: "?

  7. #7
    Join Date
    Apr 2005
    Posts
    70
    I didn't get any error message..Just : Successfully registered. Your password will be sent to your email.

  8. #8
    Join Date
    Jan 2009
    Posts
    3,346
    Can you check the mail server logs to see if the email was sent and you just didn't receive it?

  9. #9
    Join Date
    Apr 2005
    Posts
    70
    Actually there was technical error.I checked the email (marin-dbase.com) and i saw the email from the website (that i register on friday)..So, it still the same..the same problem that i faced before ..the email was send but it didn't insert to the database.im wondering why it only happened for the certain mail address..

  10. #10
    Join Date
    Jan 2009
    Posts
    3,346
    Can we see the code you are using for the insert after you've implemented my suggestion to output any errors from the database?

  11. #11
    Join Date
    Apr 2005
    Posts
    70
    I am really blur what is the problem because i ve used the same code and applied it to my client database and everything was fine and there is no problem.

    Here is the code (insert)
    HTML Code:
    <? include("../inc/fungsi.inc") ?>
    <script>
    function check(){
    	if(document.frm.salutation.value==""){
    			alert("Please fill in your salutation! ");
    			document.frm.salutation.focus();
    			return false;
    		}
    	if(document.frm.name.value==""){
    			alert("Please fill in your name! ");
    			document.frm.name.focus();
    			return false;
    		}
    	if(document.frm.nationality.value==""){
    			alert("Please choose your nationality! ");
    			document.frm.nationality.focus();
    			return false;
    		}
    	if(document.frm.organization.value==""){
    			alert("Please fill in your organization name! ");
    			document.frm.organization.focus();
    			return false;
    		}
    	if(document.frm.position.value==""){
    			alert("Please fill in your position! ");
    			document.frm.position.focus();
    			return false;
    		}
    	
    	if(document.frm.address.value==""){
    			alert("Please fill in your address! ");
    			document.frm.address.focus();
    			return false;
    		}
    	
    	if(document.frm.postal_code.value==""){
    			alert("Please fill in your postal code! ");
    			document.frm.postal_code.focus();
    			return false;
    		}
    	if(document.frm.city.value==""){
    			alert("Please fill in your city! ");
    			document.frm.city.focus();
    			return false;
    		}
    	if(document.frm.state.value==""){
    			alert("Please fill in your state! ");
    			document.frm.state.focus();
    			return false;
    		}
    	if(document.frm.country.value==""){
    			alert("Please choose your country! ");
    			document.frm.country.focus();
    			return false;
    		}
    	if(document.frm.email.value==""){
    			alert("Fill in your Email! ");
    			document.frm.email.focus();
    			return false;
    		}
    		mail=document.frm.email.value
    		at_pos=mail.indexOf("@")
    		dot_pos=mail.indexOf(".")
    		if(at_pos<1 || dot_pos<1){
        		alert("Email Not valid");
        		document.frm.email.focus();
        		return false;
    		}
    	if(document.frm.username.value==""){
    			alert("Please fill in your preferred username! ");
    			document.frm.username.focus();
    			return false;
    		}
    		return true;
    	}
    </script>
    <br />
    <table cellpadding="0" cellspacing="1" border="0" width="700" align="center">
    	<tr>
    		<td class="colorContent" height="25" colspan="7"><span class="teks08">&nbsp;Member Registration</span></td>
    	</tr>
    	<tr>
    		<td colspan="3" height="15"></td>
    	</tr>
    	<tr> 
    		<td  colspan="3">
    			<table cellpadding="0" cellspacing="0" width="640" align="center">
    				<tr>
    					<td><span class="teks06">Please fill in all information below. Your registration is subjected to approval by the administrator. Password will be send to your email.
    					</span></td>
    				</tr>
    				<tr>
    					<td height="15"></td>
    				</tr>
    				<tr>
    					<td>
    						<form name="frm" method="post" action="index.php?menu=registrationExpert" onSubmit="return check()">
    						<table cellpadding="1" cellspacing="0" width="100&#37;">
    							<tr>
    								<td width="120"><span class="teks03">Salutation/Designation</span></td>
    								<td>&nbsp;:&nbsp;<input type="text" class="mybox" name="salutation" size="30" value="<?php echo $_POST['salutation']; ?>"><span class="teks05">&nbsp;(Prof/Assoc. Prof/Dr/Datuk/Ir/Mr/etc)</span></td>
    							</tr>
    							<tr>
    								<td width="120"><span class="teks03">Name</span></td>
    								<td>&nbsp;:&nbsp;<input type="text" class="mybox" name="name" size="30" value="<?php echo $_POST['name']; ?>">
    								<span class="teks05">&nbsp;</span></td>
    							</tr>
    							<tr>
    								<td><span class="teks03">Nationality</span></td>
    								<td>&nbsp;:
    								<?php $country=$_POST['nationality']; ?>
    								<select name="nationality" class="mybox">
    									<option value="" selected>-- Select Nationality --</option>
    								<?php LoadCountries($country); ?></select></td>
    							</tr>
    							<tr>
    								<td><span class="teks03">Organization Name</span></td>
    								<td>&nbsp;:&nbsp;<input type="text" class="mybox" name="organization" size="30" value="<?php echo $_POST['organization']; ?>"></td>
    							</tr>
    							<tr>
    								<td><span class="teks03">Position</span></td>
    								<td>&nbsp;:&nbsp;<input type="text" class="mybox" name="position" size="30" value="<?php echo $_POST['position']; ?>"></td>
    							</tr>
    							<tr>
    								<td><span class="teks03">Address</span></td>
    								<td>&nbsp;:&nbsp;<input type="text" class="mybox" name="address" size="60" value="<?php echo $_POST['address']; ?>"></td>
    							</tr>
    							
    							<tr>
    								<td><span class="teks03">Postal Code</span></td>
    								<td>&nbsp;:&nbsp;<input type="text" class="mybox" name="postal_code" size="10" value="<?php echo $_POST['postal_code']; ?>">&nbsp;&nbsp;
    								<span class="teks03">City</span>&nbsp;:&nbsp;<input type="text" class="mybox" name="city" size="30" value="<?php echo $_POST['city']; ?>"></td>
    							</tr>
    							<tr>
    								<td><span class="teks03">State</span></td>
    								<td>&nbsp;:&nbsp;<input type="text" class="mybox" name="state" size="20" value="<?php echo $_POST['state']; ?>">&nbsp;&nbsp;
    								<span class="teks03">Country</span>&nbsp;:&nbsp;
    								<?php $country=$_POST['country']; ?>
    								<select name="country" class="mybox">
    									<option value="" selected>-- Select Country --</option>
    								<?php LoadCountries($country); ?></select></td>
    							</tr>
    							<tr>
    								<td><span class="teks03">Contact No.</span></td>
    								<td>&nbsp;:&nbsp;<input type="text" class="mybox" name="contactNo" size="15" value="<?php echo $_POST['contactNo']; ?>">
    								&nbsp;<span class="teks03">Fax No.</span>&nbsp;:&nbsp;
    								<input type="text" class="mybox" name="faxNo" size="15" value="<?php echo $_POST['faxNo']; ?>"></td>
    							</tr>
    							<tr>
    								<td><span class="teks03">Email</span></td>
    								<td>&nbsp;:&nbsp;<input type="text" class="mybox" name="email" size="30" value="<?php echo $_POST['email']; ?>"> &nbsp;<span class="teks03">Website</span>&nbsp;:&nbsp;<input type="text" class="mybox" name="website" size="30" value="<?php echo $_POST['website']; ?>"></td>
    							</tr>
    							<tr>
    								<td colspan="2" height="5"></td>
    							</tr>
    							
    							<tr>
    								<td colspan="2"><span class="teks06">Fill in your preferred username.</span></td>
    							</tr>
    							<tr>
    								<td colspan="2" height="5"></td>
    							</tr>
    							<tr>
    								<td><span class="teks03">Username</span></td>
    								<td>&nbsp;:&nbsp;<input type="text" class="mybox" name="username" size="30"></td>
    							</tr>
    						  </table>
    							
    
    	<table width="698">
    							<tr>
    								<td width="128"></td>
    								<td width="558">&nbsp;&nbsp;&nbsp;
    								  <input type="submit" name="submit" value="submit" size="12">
    							  <input type="reset" name="reset" value="reset" size="12"></td>
    							</tr>
    						</table>
    						</form>
    					</td>
    				</tr>
    			</table>
    		</td>
        </tr>
    	
    </table>

  12. #12
    Join Date
    Jan 2009
    Posts
    3,346
    Where is the PHP code that manipulates the database and sends the email?

  13. #13
    Join Date
    Apr 2005
    Posts
    70
    The first post is the code that manipulates the database and sends the email..you have to scroll down and u fill find it..

  14. #14
    Join Date
    Jan 2009
    Posts
    3,346
    Quote Originally Posted by inventive View Post
    The first post is the code that manipulates the database and sends the email..you have to scroll down and u fill find it..
    I suggested a change to that code and you said that it still wasn't working so I asked to see what you changed it to. This is not an html/javascript issue so we don't need to see the code you just posted, only the updated php code from your first post.

  15. #15
    Join Date
    Apr 2005
    Posts
    70
    Dear criterion9, i'm really sorry for the late reply coz i'm really busy..I ve detected the prob..The problem is my friend who created the table did a mistake..He wrote the length of the email = varchar(20)..So, when someone insert their email that has length more than 20,the system will not insert it to the database.so,that's only the problem..
    Thanks for your concern about this..

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles