Jump to content

registration for auto login


pixeltrace

Recommended Posts

guys,

 

i need help, before my registration form is working in such a way when after registering you will automatically

be directed to your profile page.

 

know, what i did is i just added a validation page for picking up errors on the page

and after that, the auto-direct is no longer working.

 

this is my process i have a registration form, after filling up the form and everything is correct and valid

you will know be directed to your profile page.

 

below is the codes for my registration form

<form action="registrationsend.php" method="post">
                  <table width="216" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td colspan="3" valign="top" bgcolor="#B30110"><img src="images/spacer.gif" width="1" height="1" /></td>
                    </tr>
                    <tr>
                      <td align="left" bgcolor="#B30110" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
                      <td width="214" valign="top"><table width="530" border="0" cellspacing="2" cellpadding="3">
                          <tr>
                            <td colspan="4" valign="top"><img src="../images/main/spacer.gif" width="1" height="1" /></td>
                          </tr>
                          <tr>
                            <td colspan="4" bgcolor="#999999" class="text9">PERSONAL INFORMATION </td>
                          </tr>
                          <tr>
                            <td colspan="4" valign="top"><img src="../images/main/spacer.gif" width="1" height="1" /></td>
                          </tr>
                          <tr>
                            <td width="159" align="right" valign="top" class="text6"><span class="text3">*</span>Email  :</td>
                            <td> </td>
                            <td width="340" colspan="2" class="text8"><input type="text" name="email1" class="field3">
                              this will be your Login ID</td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6"><span class="text3">*</span>re-type Email : </td>
                            <td width="5" rowspan="2"> </td>
                            <td colspan="2"><span class="text7">
                              <input type="text" name="email2" class="field3">
                            </span></td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6"><span class="text3">*</span>Password : </td>
                            <td colspan="2"><span class="text8">
                              <input type="password" name="password1" class="field3">
                              6 to 60 characters</span></td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6"><span class="text3">*</span>re-type Password   : </td>
                            <td> </td>
                            <td colspan="2"><span class="text7">
                              <input type="password" name="password2" class="field3">
                            </span></td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6"><span class="text3">*</span>First Name : </td>
                            <td> </td>
                            <td colspan="2"><span class="text7">
                              <input type="text" name="fname" class="field3">
                            </span></td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6"><span class="text3">*</span>Last Name  : </td>
                            <td> </td>
                            <td colspan="2"><span class="text7">
                              <input type="text" name="lname" class="field3">
                            </span></td>
                          </tr>
                          <tr>
                            <td align="right"><span class="text6">Date of Birth  : </span></td>
                            <td> </td>
                            <td colspan="2"><span class="text7">
                              <select name="daybirth" class="field3">
                                <option value='1'>1</option>
                                <option value='2'>2</option>
                                <option value='3'>3</option>
                                <option value='4'>4</option>
                                <option value='5'>5</option>
                                <option value='6'>6</option>
                                <option value='7'>7</option>
                                <option value='8'>8</option>
                                <option value='9'>9</option>
                                <option value='10'>10</option>
                                <option value='11'>11</option>
                                <option value='12'>12</option>
                                <option value='13'>13</option>
                                <option value='14'>14</option>
                                <option value='15'>15</option>
                                <option value='16'>16</option>
                                <option value='17'>17</option>
                                <option value='18'>18</option>
                                <option value='19'>19</option>
                                <option value='20'>20</option>
                                <option value='21'>21</option>
                                <option value='22'>22</option>
                                <option value='23'>23</option>
                                <option value='24'>24</option>
                                <option value='25'>25</option>
                                <option value='26'>26</option>
                                <option value='27'>27</option>
                                <option value='28'>28</option>
                                <option value='29'>29</option>
                                <option value='30'>30</option>
                                <option value='31'>31</option>
                              </select>
                              <select name="monthbirth" class="field3">
                                <option value='1'>Jan</option>
                                <option value='2'>Feb</option>
                                <option value='3'>Mar</option>
                                <option value='4'>Apr</option>
                                <option value='5'>May</option>
                                <option value='6'>Jun</option>
                                <option value='7'>Jul</option>
                                <option value='8'>Aug</option>
                                <option value='9'>Sep</option>
                                <option value='10'>Oct</option>
                                <option value='11'>Nov</option>
                                <option value='12'>Dec</option>
                              </select>
                               
                              <input name="yearbirth" type="text" size="8" class="field3">
                              (YYYY) </span></td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6">Gender : </td>
                            <td> </td>
                            <td colspan="2" class="text7"><input name="gender" type="radio" value="Male" />
                              Male
                              <input name="gender" type="radio" value="Female" />
                              Female </td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6"><span class="text3">*</span>Contact number : </td>
                            <td> </td>
                            <td colspan="2" class="text7"><input type="text" name="contact" class="field3">
                              <span class="text3">* include area code & country code</span> </td>
                          </tr>
                          <tr>
                            <td align="right" class="text6">Country of Residence : </td>
                            <td> </td>
                            <td colspan="2"><select name="country" class="field3">
                                <option value="Afghanistan">Afghanistan</option>
                                <option value="Albania">Albania</option>
                                <option value="Algeria">Algeria</option>
                            </select></td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6">State/ Region : </td>
                            <td> </td>
                            <td colspan="2"><span class="text7">
                              <input type="text" name="state" class="field3">
                            </span></td>
                          </tr>
                          <tr>
                            <td colspan="4" bgcolor="#999999" class="text9">CAREER PREFERENCES / INFORMATION </td>
                          </tr>
                          <tr>
                            <td colspan="4" valign="top"><img src="../images/main/spacer.gif" width="1" height="1" /></td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6"> </td>
                            <td align="right" valign="top" class="text6"> </td>
                            <td colspan="2" valign="top" class="text6"><span class="text3">*</span>Select your preferred Job Specialization<br>
                                <span class="text3">you can select up to 10 preferred specialization</span> </td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6"> </td>
                            <td align="right" valign="top" class="text6"> </td>
                            <td colspan="2" valign="top" class="text6"><select name="specialization[]" size="8" class="field3" multiple>
                                <?
include 'db_connect.php';
$uSql = "SELECT specialization FROM specialization ORDER by sid ASC";
$uResult = mysql_query($uSql, $connection);
if(!$uResult){
echo 'no data found';
}
else{
while($uRow = mysql_fetch_row($uResult)){
?>
                                <option value="<?= $uRow[0]?>">
                                <?= $uRow[0]?>
                                </option>
                                <?
    }    
}
?>
                              </select>                            </td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6"> </td>
                            <td align="right" valign="top" class="text6"> </td>
                            <td colspan="2" valign="top" class="text3">* press CTRL then click on the items you wish to select </td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6">Experience Level  :</td>
                            <td align="right" valign="top" class="text6"> </td>
                            <td colspan="2" valign="top" class="text7"><select name="level" class="field3">
                              <option value=""></option>
                              <?php
	$uSql = "SELECT level FROM level";
	$uResult = mysql_query($uSql, $connection);

	while($uRow = mysql_fetch_array($uResult)){
		echo "<option value=\"". $uRow['level'] ."\">". $uRow['level'] ."\n";
	}    
?>
                            </select></td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6"> </td>
                            <td> </td>
                            <td colspan="2"> </td>
                          </tr>
                          <!--<tr>
                        <td align="right" valign="top" class="text6">Text Resume : </td>
                        <td colspan="2">*Please copy and paste your <strong>FULL</strong> resume below.</td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6"><textarea name="textarea" cols="85" rows="20"></textarea></td>
                      </tr>-->
                          <tr>
                            <td colspan="4" valign="top" class="text6"><hr></td>
                          </tr>
                          <tr>
                            <td colspan="4" valign="top" class="text6">I learned about JobHiRings from : <span class="text7">
                              <input type="text" name="learned" class="field3">
                            </span></td>
                          </tr>
                          <tr>
                            <td colspan="4" valign="top" class="text6"><hr></td>
                          </tr>
                          <tr>
                            <td colspan="4" align="center" valign="top" class="text6"><input type="submit" name="Submit" value="Register" class="textfield1" />
                              <input type="hidden" name="sender" value="[email protected]" />
                              <input type="hidden" name="accounttype" value="applicant" />
                              <input type=hidden value=http://www. name=redirect></td>
                          </tr>
                          <tr>
                            <td align="right" valign="top" class="text6"> </td>
                            <td> </td>
                            <td colspan="2"> </td>
                          </tr>
                      </table></td>
                      <td align="right" bgcolor="#B30110" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
                    </tr>
                    <tr>
                      <td colspan="3" valign="top" bgcolor="#B30110"><img src="images/spacer.gif" width="1" height="1" /></td>
                    </tr>
                  </table>
              </form>

 

 

this is the code for my registrationsend.php

<?
include '../admean/db_connect.php';
include("validate.php");
$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$daybirth = $_POST['daybirth'];
$monthbirth = $_POST['monthbirth'];
$yearbirth = $_POST['yearbirth'];
$gender = $_POST['gender'];
$contact = $_POST['contact'];
$country = $_POST['country'];
$state = $_POST['state'];
$specialization = implode("\n", $_POST['specialization']);
$level = $_POST['level'];
$sender = $_POST['sender'];
$accounttype = $_POST['accounttype'];
//$photofile = $_POST['photofile'];
//$resume = $_POST['resume'];
$learned = $_POST['learned'];
$dateregistered = date('Y-m-d');
// 0000-00-00
$datebirth = $yearbirth.'-'.$monthbirth.'-'.$daybirth;

if ($email1=='' or $email2=='' or $password1=='' or $password2=='' or $fname=='' or $lname=='' or $contact=='')  { 
         error ('Kindly fill in the fields with (*).\\n'.'Thank you!');
    }
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email1)){ 
  error("Invalid e-mail address");
  }

//email verification 1
if ($email1 == $email2){
	$email = $email1;
	$username = $email1;
	}else { 
		error ('Email Address does not match!');
}
//email verification 2
$sql_username_check = mysql_query("SELECT username FROM applicant WHERE email='$email'");
  $username_check = mysql_num_rows($sql_username_check);
	if($username_check > 0){
		error ('Email Address already in use!');

	} 	 
//password verification
if ($password1 == $password2){
	$password = ($password1);
	}else { 
	error ('Password does not match!');

}

$email = stripslashes($email);
$username = stripslashes($username);
$password = stripslashes($password);
$fname = stripslashes($fname);
$lname = stripslashes($lname);
$datebirth = stripslashes($datebirth);
$gender = stripslashes($gender);
$contact = stripslashes($contact);
$country = stripslashes($country);
$state = stripslashes($state);
$specialization = stripslashes($specialization);
$level = stripslashes($level);
$accounttype = stripslashes($accounttype);
//$photofile = stripslashes($photofile);
//$resume = stripslashes($resume);
$learned = stripslashes($learned);
$dateregistered = stripslashes($dateregistered);

$db_password = md5($password);

$special = $_POST['specialization'];
foreach($special as $key=>$val){
//print "$key".$val;

$sql="UPDATE specialization SET hits = hits + 1 WHERE specialization LIKE '%". $val ."%'";
	mysql_query($sql) or die("error:".mysql_error());
}

$sql = mysql_query("INSERT INTO applicant (email, username, password, account_type, fname, lname, datebirth, gender, contact, country, state, specialization, level, learned, dateregistered )
      VALUES('$email', '$username', '$db_password', '$accounttype', '$fname', '$lname', '$datebirth', '$gender', '$contact', '$country', '$state', '$specialization', '$level', '$learned', '$dateregistered')") or die (mysql_error());

     if(!$sql){
    error ('Error adding your account. Please try again!');

     } else {
   $appid = mysql_insert_id();	   
echo '<script language=javascript> alert("Thank you for registering!");top.location = "../accounts/profile.php?id=1&username='.$username.'";</script>';
    }
// -- send registrant email copy
$Message = "";
$Message .= "Hello $name\n";
$Message .= "Thank you for signing up at JobHirings\n";
$Message .= "\n\n";
$Message .= "Below is a copy of your account details\n";
$Message .= "-------------------------\n";
$Message .= "Email ID: $email\n";
$Message .= "Password: $password\n";
$Message .= "-------------------------\n";
$Message .= "\n\n";
$Message .= "Please make sure to visit our website to check\n";
$Message .= "fresh new job vaccancy that's just meant for you\n";
$Message .= "Again, thank and good luck to your career\n";
$Message .= "\n\n";

$Header = $sender;
$To = "$email";
$Subject = "Thank you for signing up at JobHiRings"; 

// mail($To,$Subject,$Message,"From: $Header","-f $EmailAdd"); last parameter might not be supported
mail($To,$Subject,$Message,"From: $Header");


?>

 

and this is the code for my profile page

<?php
session_start();
if (session_is_registered("username")){
$username = $_SESSION['username'];

include '../admean/db_connect.php';
$query = mysql_query("SELECT appid, fname, lname FROM applicant WHERE username= '$username'") or die(mysql_error()); 
$row = mysql_fetch_array( $query );
$fname = $row["fname"];
$lname  = $row["lname"];
$appid  = $row["appid"];

if (!isset($id)) { $id='1';} 
?>
some text table and text here
<? 
}else{
echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='../index.php'>Login</a></font>";
}
?>

 

 

hope you could hglp me with this.

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/45701-registration-for-auto-login/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.