son.of.the.morning
-
Posts
292 -
Joined
-
Last visited
Never
Posts posted by son.of.the.morning
-
-
I want kind of work around the code i already have, how would i go about keeping the existing code but modifying to the theory in which you have?
Here is what i have
checklogin.php
<?php $host="xxxxxxxx"; // Host name $username="xxxxxxxxx"; // Mysql username $password="xxxxxxxx"; // Mysql password $db_name="a2820511_admin"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name 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?id=$myusername"); } else { echo "Wrong username or password..."; } ?>
login-success.php
<? session_start(); if(!session_is_registered(myusername)){ header("location:main_login.php"); } $myusername; welcome ?>
-
I am using a login system in php and mySQL but only one page is potected.
pages i am using:
1. login.php // inputing details (user name, password)
2. checkloginDetails.php // connect to db and check login details
3. logged_in.php // successfully login
...i need more than the one page protected for example; once the user has logged in there will be the main logged in page with other links, remove topics, add, user, remove user all these pages i want protecting but with out the user inputing his details again.
Has anyone got an idear onhow i ould achive this?
-
Ya i got that, i have it working now, i used a redirect in javascript so once the php has taken place it returns back to the record list page.
you think that will be fine?
-
i cant change the id to x, becuase i am passing a var through it, here is my code
<?php
$host="------"; // Host name
$username="------"; // Mysql username
$password="------"; // Mysql password
$db_name="--------"; // Database name
$tbl_name="forum_question"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$id=$_GET['id'];
?>
><a href="<? mysql_query("DELETE FROM forum_question WHERE id='$id'"); ?>">yes</a></p>
-
I have finaly got my removing recods page working, but i do have one problem...
i have a delete button which goes to a new php page which contains the DELETE FROM, this deletes the record automaticaly. There are two paths which i could choose from the problem is i am stuck on both of them.
1. a link that will activate the delete code.
2. once the record has been deleted then it will automaticaly go back the the first page.
can any one help me here please?
-
There is no actual problem, other than i havnt got a clue were to start am first time user of php.
-
Hey again guys,
i am building a site admin page and i want to do a php script with will show the heading and the date of my news database into a table, and on the right or left side of each row i want to put 2 small icons one which will remove the specific record and one which will open a new small window with the whole record viewing.
any idears?
-
Not really would rather do it myself that way if i ever encounter this problem again then i know what to do.
-
Am i able to format it the way i want though?
-
Hi guys,
i want to make a small html editor for a new updater, basicaly somthink the same as what am writing in now. For example if i wanted to add an image for a href to the post i would have button aside from the text box which would insert the tag "//<a href="http://google.com">link</a>"
any idears?
-
That worked like a charm, thanks allot man. I wonder if you can help me with a another php issue, i am going to be building a tutorial site and i want a search utility within it, how would i come about doing this?
-
No the insert new record is on a totally different page. I just want to selected the post recently added record.
For example: if I added a new record to the database and went on the news page were i am trying to select a record it would show only the last record i inserted.
Do you understand me?
-
Hey,
I want to selected the most recent update in my sql database, i am using this at the moment
$sql="SELECT * FROM $tbl_name WHERE id='6'";
$result=mysql_query($sql);
Which is just selecting the record that has the id "6"
any suggestions...?
Login system in php & mySQL
in PHP Coding Help
Posted
How is it the session var (myusername) is passed to page to page?