Jump to content

mikebyrne

Members
  • Posts

    780
  • Joined

  • Last visited

Everything posted by mikebyrne

  1. Brilliant!! Now what i wanted to do was but a bit of rediredtion because I've 2 types of users the code for users = 1 admin =0 I wanted something like this but cant seem to get it to work! $defaultPage = "customer/index.php"; if($rows['user'] == "1") { $defaultPage = "emp/index.php"; } header("location:$defaultPage");
  2. It seems to take in the code but just displays the login screen again
  3. I'm trying to get my login screen working but im getting loads of errror: Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\checklogin.php:2) in C:\xampp\htdocs\checklogin.php on line 23 Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\checklogin.php:2) in C:\xampp\htdocs\checklogin.php on line 23 Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\checklogin.php:2) in C:\xampp\htdocs\checklogin.php on line 25 Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 My code is: Main Login <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Member Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="myusername" type="text" id="myusername"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="mypassword" type="text" id="mypassword"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> Checklogin <?php ob_start(); include('config.php'); // Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $tbl_name2="users"; $sql="SELECT * FROM $tbl_name2 WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ob_end_flush(); ?> Confirm <?php include('config.php'); // Passkey that got from link ## added here if (!isset($_GET['passkey'])) { echo "Error here :: Validation Failed"; }else{ //Cleanup $passkey = mysql_escape_string($_GET['passkey']); ## table name $tbl_name="temp_users"; $tbl_name2="users"; // after connecting succesfully: $sql1 = "SELECT * FROM $tbl_name WHERE confirm_code ='$passkey'"; $result = mysql_query($sql1) or die(mysql_error()); $found = mysql_num_rows( $result); if($found > 0) { //Don't need loop as only 1 record is valid per passkey $row = mysql_fetch_array($result); $sql2="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password, user)VALUES('".$row['name'] . "', '".$row['address'] . "', '".$row['address1'] . "', '".$row['address2'] . "', '".$row['address3'] . "', '".$row['address4'] . "', '".$row['county'] . "', '".$row['zip'] . "', '".$row['telephone'] . "', '".$row['email'] . "', '".$row['username'] . "', '".$row['password'] . "', 1)"; $result2=mysql_query($sql2)or die(mysql_error()); echo "Your account has been activated"; $sql3="DELETE FROM $tbl_name WHERE confirm_code = '$passkey'"; $result3=mysql_query($sql3)or die(mysql_error()); }else{ echo "Error here :: PASSKEY NOT FOUND "; } } ?> Loginsuccess // Check if session is not registered , redirect back to main page. // Put this code in first line of web page. <?php session_start(); if(!session_is_registered(myusername)){ header("location:main_login.php"); } ?> <html> <body> Login Successful </body> </html>
  4. Thats great, thaks! I'm working on my login section now. I've never seen so many errors!! LOL I'll work on it for a bit and look for help if im stuck Again, thanks for your help
  5. Sorry 1 more question In my scenario the user clicks on a confirmation email to activate the account. Wouldn't this part of the code never come into play??? // Passkey from link if (!isset($_GET['passkey'])) { echo "Error here :: PASSKEY NOT ENTERED";
  6. Thats fantastic and really has cleaned up the code!!! THANKS Could you explain what these lines do? $passkey = mysql_escape_string($_GET['passkey']); AND while ($row = mysql_fetch_array($result))
  7. I want this code to show an error if the passkey is not found, but at present if the passkey doesn't exist it just show a blank screen <?php include('config.php'); $passkey=$_GET['passkey']; // Passkey that got from link ## added here if (!isset($_GET['passkey'])) { echo "Error here :: PASSKEY NOT FOUND "; } else { ## table name $tbl_name="temp_users"; $tbl_name2="users"; // after connecting succesfully: $sql1 = "SELECT * FROM $tbl_name WHERE confirm_code ='$passkey'"; $result = mysql_query($sql1) or die(mysql_error()); // while there is a result, fetch it into an array... while ($row = mysql_fetch_array($result)) { $sql2="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password, user)VALUES('".$row['name'] . "', '".$row['address'] . "', '".$row['address1'] . "', '".$row['address2'] . "', '".$row['address3'] . "', '".$row['address4'] . "', '".$row['county'] . "', '".$row['zip'] . "', '".$row['telephone'] . "', '".$row['email'] . "', '".$row['username'] . "', '".$row['password'] . "', 1)"; $result2=mysql_query($sql2)or die(mysql_error()); echo "Your account has been activated"; $sql3="DELETE FROM $tbl_name WHERE confirm_code = '$passkey'"; $result3=mysql_query($sql3)or die(mysql_error()); } } ?>
  8. This solved my problem <?php include('config.php'); $passkey=$_GET['passkey']; // Passkey that got from link ## added here if (!isset($_GET['passkey'])) { echo "Error here :: PASSKEY NOT FOUND "; } else { ## table name $tbl_name="temp_users"; $tbl_name2="users"; // after connecting succesfully: $sql1 = "SELECT * FROM $tbl_name WHERE confirm_code ='$passkey'"; $result = mysql_query($sql1) or die(mysql_error()); // while there is a result, fetch it into an array... while ($row = mysql_fetch_array($result)) { $sql2="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password, user)VALUES('".$row['name'] . "', '".$row['address'] . "', '".$row['address1'] . "', '".$row['address2'] . "', '".$row['address3'] . "', '".$row['address4'] . "', '".$row['county'] . "', '".$row['zip'] . "', '".$row['telephone'] . "', '".$row['email'] . "', '".$row['username'] . "', '".$row['password'] . "', 1)"; $result2=mysql_query($sql2)or die(mysql_error()); echo "Your account has been activated"; $sql3="DELETE FROM $tbl_name WHERE confirm_code = '$passkey'"; $result3=mysql_query($sql3)or die(mysql_error()); } } ?>
  9. I would like my code to delete the relevant confirm_code from the temp_users table but I'm getting the error Your account has been activatedYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE confirm_code = '5f6feb0f5d104c2a6b7ce24d40711f74'' at line 1 My code is <?php include('config.php'); $passkey=$_GET['passkey']; // Passkey that got from link ## added here if (!isset($_GET['passkey'])) { echo "Error here :: PASSKEY NOT FOUND "; } else { ## table name $tbl_name="temp_users"; $tbl_name2="users"; // after connecting succesfully: $sql1 = "SELECT * FROM $tbl_name WHERE confirm_code ='$passkey'"; $result = mysql_query($sql1) or die(mysql_error()); // while there is a result, fetch it into an array... while ($row = mysql_fetch_array($result)) { $sql2="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password, user)VALUES('".$row['name'] . "', '".$row['address'] . "', '".$row['address1'] . "', '".$row['address2'] . "', '".$row['address3'] . "', '".$row['address4'] . "', '".$row['county'] . "', '".$row['zip'] . "', '".$row['telephone'] . "', '".$row['email'] . "', '".$row['username'] . "', '".$row['password'] . "', 1)"; $result2=mysql_query($sql2)or die(mysql_error()); echo "Your account has been activated"; $sql3="DELETE FROM $tbl_name1 WHERE confirm_code = '$passkey'"; $result2=mysql_query($sql3)or die(mysql_error()); } } ?>
  10. Thanks I just played around with the code and solved it while ($row = mysql_fetch_array($result)) { $sql="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password, user)VALUES('".$row['name'] . "', '".$row['address'] . "', '".$row['address1'] . "', '".$row['address2'] . "', '".$row['address3'] . "', '".$row['address4'] . "', '".$row['county'] . "', '".$row['zip'] . "', '".$row['telephone'] . "', '".$row['email'] . "', '".$row['username'] . "', '".$row['password'] . "', 1)"; $result2=mysql_query($sql)or die(mysql_error()); echo "Your account has been activated"; }
  11. I've just created a field in the users table called users. I want my code to pass a 1 to that field when the user click on the confirmation link. What extra would i add to my SQL? <?php include('config.php'); $passkey=$_GET['passkey']; // Passkey that got from link ## added here if (!isset($_GET['passkey'])) { echo "Error here :: PASSKEY NOT FOUND "; } else { ## table name $tbl_name="temp_users"; $tbl_name2="users"; // after connecting succesfully: $query = "SELECT * FROM $tbl_name WHERE confirm_code ='$passkey'"; $result = mysql_query($query) or die(mysql_error()); // while there is a result, fetch it into an array... while ($row = mysql_fetch_array($result)) { $sql="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password)VALUES('".$row['name'] . "', '".$row['address'] . "', '".$row['address1'] . "', '".$row['address2'] . "', '".$row['address3'] . "', '".$row['address4'] . "', '".$row['county'] . "', '".$row['zip'] . "', '".$row['telephone'] . "', '".$row['email'] . "', '".$row['username'] . "', '".$row['password'] . "')"; $result2=mysql_query($sql)or die(mysql_error()); echo "Your account has been activated"; } } ?>
  12. I'VE GOT IT WORKING NOW THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! The code was <?php include('config.php'); $passkey=$_GET['passkey']; // Passkey that got from link ## added here if (!isset($_GET['passkey'])) { echo "Error here :: PASSKEY NOT FOUND "; } else { ## table name $tbl_name="temp_users"; $tbl_name2="users"; // after connecting succesfully: $query = "SELECT * FROM $tbl_name WHERE confirm_code ='$passkey'"; $result = mysql_query($query) or die(mysql_error()); // while there is a result, fetch it into an array... while ($row = mysql_fetch_array($result)) { $sql="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password)VALUES('".$row['name'] . "', '".$row['address'] . "', '".$row['address1'] . "', '".$row['address2'] . "', '".$row['address3'] . "', '".$row['address4'] . "', '".$row['county'] . "', '".$row['zip'] . "', '".$row['telephone'] . "', '".$row['email'] . "', '".$row['username'] . "', '".$row['password'] . "')"; $result2=mysql_query($sql)or die(mysql_error()); echo "$row[address]<br />"; echo "$row[address1]<br />"; echo "$row[name]<br />"; echo "$row[password]<br />"; } } ?>
  13. I've changed it to <?php include('config.php'); $passkey=$_GET['passkey']; // Passkey that got from link ## added here if (!isset($_GET['passkey'])) { echo "Error here :: PASSKEY NOT FOUND "; } else { ## table name $tbl_name="temp_users"; $tbl_name2="users"; // after connecting succesfully: $query = "SELECT * FROM $tbl_name WHERE confirm_code ='$passkey'"; $result = mysql_query($query) or die(mysql_error()); // while there is a result, fetch it into an array... while ($row = mysql_fetch_array($result)) { $sql="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password)VALUES('".$row['name'] . "', '".$row['name'] . "', '".$row['address'] . "', '".$row['address1'] . "', '".$row['address2'] . "', '".$row['address3'] . "', '".$row['address4'] . "', '".$row['county'] . "', '".$row['zip'] . "', '".$row['telephone'] . "', '".$row['email'] . "', '".$row['username'] . "', '".$row['password'] . "')"; $result2=mysql_query($sql)or die(mysql_error()); echo "$row[address]<br />"; echo "$row[address1]<br />"; echo "$row[name]<br />"; echo "$row[password]<br />"; } } ?> But now im getting the error Column count doesn't match value count at row 1
  14. The only value that passes to the "user" table is the username. The id field increments each time i click on the confirmation so its as if blank fields are being passed
  15. The SQL for the table I'm trying to post to is: CREATE TABLE `users` ( `id` int(4) NOT NULL auto_increment, `name` varchar(65) NOT NULL default '', `address` varchar(65) NOT NULL default '', `address1` varchar(65) NOT NULL default '', `address2` varchar(65) NOT NULL default '', `address3` varchar(65) NOT NULL default '', `address4` varchar(65) NOT NULL default '', `county` varchar(25) NOT NULL default '', `zip` varchar(65) NOT NULL default '', `telephone` varchar(25) NOT NULL default '', `email` varchar(25) NOT NULL default '', `username` varchar(65) NOT NULL default '', `password` varchar(15) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=latin1; The code I have now is: <?php include('config.php'); $passkey=$_GET['passkey']; // Passkey that got from link ## added here if (!isset($_GET['passkey'])) { echo "Error here :: PASSKEY NOT FOUND "; } else { ## table name $tbl_name="temp_users"; $tbl_name2="users"; // after connecting succesfully: $query = "SELECT * FROM $tbl_name WHERE confirm_code ='$passkey'"; $result = mysql_query($query) or die(mysql_error()); $sql="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password)VALUES('$name', '$address', '$address1', '$address2','$address3', '$address4','$county' ,'$zip', '$telephone', '$email', '$username', '$password')"; $result2=mysql_query($sql)or die(mysql_error()); // while there is a result, fetch it into an array... while ($row = mysql_fetch_array($result)) { echo "$row[address]<br />"; echo "$row[address1]<br />"; } } ?> The output is: Test:Address1 Test:Address2 It all seems to work ok but its not PASSING INFO INTO THE "USERS" Table
  16. With this code <?php include('config.php'); $passkey=$_GET['passkey']; // Passkey that got from link ## added here if (!isset($_GET['passkey'])) { echo "Error here :: PASSKEY NOT FOUND "; } else { ## table name $tbl_name="temp_users"; $tbl_name2="users"; // after connecting succesfully: $query = "SELECT * FROM $tbl_name WHERE confirm_code ='$passkey'"; $result = mysql_query($query) or die(mysql_error()); $sql="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password)VALUES('$name', '$address', '$address1', '$address2','$address3', '$address4','$county' ,'$zip', '$telephone', '$email', '$username', '$password')"; $result=mysql_query($sql)or die(mysql_error()); // while there is a result, fetch it into an array... while ($row = mysql_fetch_array($result)) { echo "$row[address]<br />"; echo "$row[address1]<br />"; } } ?> I get the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\confirm.php on line 28
  17. I think this code should do it but where would I place it? $sql="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password)VALUES('$name', '$address', '$address1', '$address2','$address3', '$address4','$county' ,'$zip', '$telephone', '$email', '$username', '$password')"; $result=mysql_query($sql)or die(mysql_error()); I'd have to also put in $tbl_name2="users";
  18. I've change the SQL to $query = "SELECT * FROM $tbl_name WHERE confirm_code ='$passkey'"; This brings up the correct figures! If i wanted to then post them to the Users table what would the code be?
  19. Ok so at leasst we know we can see the varibles!! Now how can i just show the ones specific to the confirmation code rather then looping everyting?? If i can get this bit then all i have to do is pass the varible to the users table
  20. It gives me 1299fe5f959effd9d59d5g9d5g91299fe5f959effd9d59d5g9d5g91299fe5f959effd9d59d5g9d5g91299fe5f959effd9d59d5g9d5g91299fe5f959effd9d59d5g9d5g91299fe5f959effd9d59d5g9d5g9444445klgklklklkghfgfgfgfyrtrt dgcb,jkuiuyiyutggrtjyjyjtjyhtjhjhgrtjyjyjtjyhtjhjhmhjkuou4e64er4rjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkssssssssssssssssssssssssssssssssssssssssss which seems to be Address + Address1 in a loop THINK WERE GETTING SOMEWHERE!! (What I originally want to do was post the values over from temp_users to users once the confirmation email is clicked)
  21. just change that Getting the errror You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''temp_users'' at line 1
  22. I'm getting the error Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\confirm.php on line 26 with the code <?php include('config.php'); $passkey=$_GET['passkey']; // Passkey that got from link ## added here if (!isset($_GET['passkey'])) { echo "Error here :: PASSKEY NOT FOUND "; } else { ## table name $tbl_name="temp_users"; // after connecting succesfully: $query = "SELECT * FROM '$tbl_name'"; $result = mysql_query($query) or die(mysql_error()); // while there is a result, fetch it into an array... while ($row = mysql_fetch_array($result)) { echo "$row['address']"; echo "$row['address1']"; } } ?>
×
×
  • 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.