Jump to content

jaybeeb

Members
  • Posts

    46
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jaybeeb's Achievements

Member

Member (2/5)

0

Reputation

  1. no, its still the same doesnt grab the id from the user table
  2. ok, thanks for the help. just incase I dont manage the sessions too well. How would I go about the way I was going to do it (the unsecure way)?
  3. ok, thanks. But now how do I make it so each user has their own unique page when they login. Like to say "Hello '$username' you are now logged in" before I was just going to do an sql statement calling the 'id' Thanks for the help.
  4. Hi, No - everytime a user registers they get a unique 'id' I want to use this id to display the info relevant to each user. Just need a way of getting the id into a variable, so when the user clicks login, the variable goes with them and I can use it on the next page they go to. To be honest, i am just beggining php, this is just for a small assignment, if storing the id in a session is a simple enough proccess I would like to hear it if you wouldnt mind?
  5. Ok, I have a working login form, the only thing the user enters in the form is username and password. But I want to carry the value 'id' which is in the user table along with the username and password to the next page so I can make the page unique for each user. 'id' is set up to auto-increment when each user registers. What I have at the moment is header("location:userpage.php?id=$id"); but I am not sure how to get the actual id of the user that logs in into that variable, it just comes up blank at the moment. Any help would be greatly appreciated...
  6. Only the username and password are logged into the table, nothing else? <?php include 'library/config.php'; include 'library/opendb.php'; ?> <form method="POST" action="register.php"> <table border="0" style="font-size: 15px; font-family: Tahoma; border: 1px"> <tr> <td> Username: </td> <td> <input type="text" name="username" value="<?php echo $_POST['username']; ?>" /> </td> </tr> <tr> <td> Password: </td> <td> <input type="password" name="password" value="<?php echo $_POST['password']; ?>" /> </td> </tr> <tr> <td> Address: </td> <td> <input type="text" name="text" value="<?php echo $_POST['address']; ?>" /> </td> </tr> <tr> <td> Phone: </td> <td> <input type="integer" name="text" value="<?php echo $_POST['telephone']; ?>" /> </td> </tr> <tr> <td> Email: </td> <td> <input type="text" name="text" value="<?php echo $_POST['email']; ?>" /> </td> </tr> <tr> <td> Type: </td> <td> <select input type="text" name="text" value="<?php echo $_POST['type']; ?>" /> <option>Applicant</option> <option>Employer</option> </select> </td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" name="submit" value="Register"/> </td> </tr> </table> </form> <?php if($_POST['submit']) { $username = $_POST['username']; $password = $_POST['password']; $address = $_POST['address']; $telephone = $_POST['telephone']; $email = $_POST['email']; $type = $_POST['type']; $curnum = 0; if(!$username) { $curnum ++; echo "<font color='black'>" . $curnum . ". You must enter a username.</font><Br>\n"; } if(!$password) { $curnum ++; echo "<font color='black'>". $curnum . ". You must enter a password.</font><Br>\n"; } if(!$address) { $curnum ++; echo "<font color='black'>". $curnum . ". You must enter a address.</font><Br>\n"; } if(!$telephone) { $curnum ++; echo "<font color='black'>". $curnum . ". You must enter a telephone.</font><Br>\n"; } if(!$email) { $curnum ++; echo "<font color='black'>". $curnum . ". You must enter a email.</font><Br>\n"; } $sql = "SELECT * FROM user WHERE username='".$username."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) > 0) { $curnum ++; echo "<font color='black'>".$curnum . ". The username '".$username."' already exists</font>\n"; } if($curnum == 0) { mysql_query("INSERT INTO user VALUES (`id`,'". $username ."', '".$password."','". $address ."','". $telephone ."','". $email ."','". $type ."')") or die(mysql_error()); echo "<font color ='#B22222'> <H3>You have succesfuly registered as '<b>".$username."</b>'</H3></font>\n"; echo "<a href='login3.php'><H3>Login Now</H3></a>"; } } ?>
  7. Created a Login page using php/sql but am confused , when it comes to the user actually logging in how do I make each user have their own individual page. The page format will be the same with each user but each user will be able to upload and delete a file once they login and I obvisouly I only want the user that is logged in at the time to be able to upload / delete files on somebody elses account, can anyone point me in the right direction?
  8. Sorry , bit of a PHP amateur. I tried putting echo mysql_error(); after the query but doesnt display an error. Also, what is incorrect about my query? Thanks for the help. require_once 'library/db.php'; is connecting to the db <?php // database configuration $db = array('Server' => 'localhost', 'user' => 'root', 'password' => '', database => 'emp_agency'); ?> Thanks
  9. Having problems trying to update a sql table. The first part of code is where the user edits the actual data. It brings the data in just fine i.e when this page opens the data to be edited is in the correct text boxes, but when data is changed and update is clicked, it goes back to the table gives no errors - but the data has not been edited. Any ideas? Thanks in advance, <?php require_once 'library/db.php'; //require_once 'error.php'; if (!($conn = mysql_connect('localhost', 'root', ''))) { showError(); } if (!(mysql_select_db('emp_agency', $conn))) { showError(); } $a = $_GET['id']; if (!($result = mysql_query("select * from jobs where id = '$a'", $conn))) { $conn = mysql_connect('localhost', 'root', '') OR DIE (mysql_error()); } $row =mysql_fetch_array($result); mysql_close($conn); ?> <html> <body> <form action="saveedit.php" method="post"> <table border="0"> <tr> <td> ID </td> <td> <?php echo $row['id']; ?> <input type="hidden" name="User_ID" value = "<?php echo $row['id']; ?>"> </td> </tr> <tr> <td> Job Description </td> <td> <input type="text" name="job_description" value = "<?php echo $row['job_description']; ?>"> </td> </tr> <tr> <td> Experience Required </td> <td> <input type="integer" name="experience_required" value = "<?php echo $row['experience_required']; ?>"> </td> </tr> <tr> <td> Contact </td> <td> <input type="text" name="contact" value = "<?php echo $row['contact']; ?>"> </td> </tr> </table> <input type="submit" value="Update"> </form> </body> </html> <?php require_once 'library/db.php'; //require_once 'error.php'; $User_ID = $_GET['id']; if (!($conn = mysql_connect('localhost', 'root', ''))) { showError(); } if (!(mysql_select_db('itsupport', $conn))) { showError(); } if (!($result = mysql_query("UPDATE jobs SET job_description=\"$_POST[job_description]\", experience_required=\"$_POST[experience_required]\", contact=\"$_POST[contact]\" WHERE id=\"$_POST[id]\"",$conn))) { $conn = mysql_connect('localhost', 'root', '') OR DIE (mysql_error()); } mysql_close($conn); include 'employerpage.php'; ?>
  10. Thanks, very silly of me. Can somebody mark as solved if still possible?
  11. Trying to make a simple login form. I know what I have is not very secure, but I do not need it to be secure. I just keep getting an "unexpected end" error. Any ideas? Thanks <BODY> <HTML> <?php mysql_connect("localhost","root", "") or die (mysql_error()); mysql_select_db("emp_agency") or die (mysql_error()); if($_SESSION['uid']) { echo "You are already logged in <br>\n"; } else { ?> <form method="POST" action="login3.php"> <table border="0" style="font-size: 15px; font-family: Tahoma; border: 1px solid black;"><TABLE> <TR> <TD>Username:</TD> <TD><input type="text" name="username" value="<?php echo $_POST ['username']; ?>"></TD> </TR> <TR> <TD>Password:</TD> <TD><input type="password" name="password" value="<?php echo $_POST ['password']; ?>"></TD> </TR> <TR> <TD colspan="2" align="center"> <input type="submit" name="submit" value="login"></TD> </TR> </TABLE> </form> <?php if($_POST['submit']) { $curnum = 0; $username = $_POST['username']; $password = $_POST['password']; if(!$username) { $curnum ++; echo $curnum . ". You need to enter a username!<br>\n"; } if(!$password) { $curnum ++; echo $curnum . ". You need to enter a password|<br>\n"; } $sql = "SELECT * FROM user WHERE username='".$username."'"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($res); if(isset($username) && isset($password)) { if(mysql_num_rows($res) == 0) { $curnum ++; echo $curnum . ". The username '<b>".$username."</b>' does not exist<br>\n"; } if(mysql_num_rows($res) == 1) { //the username does not exist if($password != $row['password']) { $curnum ++; echo $curnum .". Wrong password,br.\n"; } if($curnum == 0) { $_SESSION['uid'] = $row['id']; } } } } ?> </BODY> </HTML>
  12. Got this working , code I ended up using was very similar to my update. Just posting for people who search this in the future. Thanks everybody for your help <?php require_once 'library/db.php'; if (!($conn = mysql_connect('localhost', 'root', ''))) { showError(); } if (!(mysql_select_db('itsupport', $conn))) { showError(); } $a = $_GET['id']; $query=mysql_query("delete FROM itsupport WHERE User_ID='$a'", $conn); if ($query) echo "The record was successfully deleted. <br><br>"; else echo "Failed to delete the record <br><br>"; mysql_close($conn); include 'currentissues.php'; ?>
  13. Line 16 you were missing a ';' and line 17 you had an extra '}' after these were sorted I get an error Thanks,
×
×
  • 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.