-
Posts
1,285 -
Joined
-
Last visited
Never
Everything posted by ohdang888
-
alright! sessions it is. I've been trying that anyways... my code is below. But one problem. I don't think the session is beginning because when i click logout, (all it contains is session_destroy().) then its say that error:trying to destory a session that doesn't exist. whats wrong? Login.php session_start(); mysql_connect("localhost", "", "") or die(mysql_error()); mysql_select_db("members") or die(mysql_error()); //remove slashes $email=stripslashes($_POST['email']); $password=stripslashes($_POST['password']); //encrypt password $encpass = md5($password); mysql_real_escape_string($email); mysql_real_escape_string($password); $sql="SELECT * FROM `users` WHERE email='$email' and password='$encpass'"; $result=mysql_query($sql); $count=mysql_num_rows($result); $user_info = mysql_fetch_array($result); $id = stripslashes($user_info['id']); if($count==1){ // if user login is successful then create session and direct to members.php $_SESSION['email']=$email; $_SESSION['id']=$id; echo "<meta http-equiv='refresh' content='0;url=member_home.php'>"; }else { // if user login is wrong direct to failed.php session_destroy(); echo "<meta http-equiv='refresh' content='0;url=failed.php'>"; }
-
whats better... cookie or session? I want to store an member 'id' number in the session or cookie
-
is it more efficent to name a session?
-
i installed XAMPP, which uses Mercury mail. Does any one of any really good tutorials on how to set up e-mails on it, and also a script that would to automatically send emails for account confirmation??? thanks
-
everyone, correct me if i'm wrong on this, but i think i know... when you do this: mysql_query($query) You are saying, carry out the command stored in the string "$query" you really wouldn't even need to put the "$result" in your command (ex. $result = mysql_query($query)), because you are making something, and no info is being drawn from it. But if your query was getting info from a database, then you would need to use $result btw!!!!! modify this in your thread to look like mine below . You just put your database username and password out there for us to see. we don't know your site, but if we every figured out the name of your site, that could be used against you. BUT DON"T change it in your file. $connect = mysql_connect ("local host", "-----", "------") or die ("can not connect");
-
ok. it makes a little more sense now! but a few questions... 1)if they go a page that does not require to be logged in, will their session be lost? 2)There is a page both members, and non-members can see, but only members can leave comments, etc.... How would i do that? just a session_start(); at the top????? 3)So session id obviously starts are log in, so to get the id for the session, would it be this? And when would the session be destoryed, only when they log out, or also when they close their browser? $user_info = mysql_fetch_array($result); $id = stripslashes($user_info['id']); if($count==1){ // if user login is successful then create session and direct to members.php $_SESSION['email']=$email; $_SESSION['id']=$id; echo "<meta http-equiv='refresh' content='0;url=member_home.php'>"; }else { // if user login is wrong direct to failed.php session_destroy(); echo "<meta http-equiv='refresh' content='0;url=failed.php'>"; }
-
i'm using sessions... When someone logs in, the session starts. Each members has an "id". And i have an "edit_settings.php?id=NUMBER OF MEMBER" So how would i make sure that only the person signed in with the session id of "4", could only change their own settings? <?php // always start a session session_start(); // if user does not have session open, direct them to login.php if (!isset($_SESSION['email'])){ header("Location:login.php"); exit(); } ?>
-
the error i am getting is this: but i can't it out!!!::: 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 'FROM `users` WHERE `id`= '1'' at line 1 i think the problem may be how the one is like this '1" (different quotes) heres the code its refering to: $result = mysql_query("SELECT `first_name`,`last_name`,`username`, `email`, FROM `users` WHERE `id`= '{$id}' ") or die(mysql_error()); $user_data = mysql_fetch_array($result);
-
thanks! but a few questions... 1) where is the info in the session stored? 2) recommend using session names?
-
hey. Does anyone knwo of any really good tutorials about hwo to create a login system with php and mysql?
-
nope, you're gonna have to code it.
-
How does the return true and return false work???
-
how do i validate an email address?????/... like... make sure there is an @ and a .com, or.net, etc. i tried the code below but it didn;t work. if(!validate_email_address($email)){
-
my code is below... IN edit_settings.php, i have a form... it has 2 radio buttons per question, a yes and no. the value of Yes is 1, and the value of No is 2. then this code is on the back end of that form, in change_settings.php there are no errors, but its not updating it. function sql_quote($data) { if (get_magic_quotes_gpc()) { $data = stripslashes($data); } return addslashes($data); } $id = sql_quote($_GET['id']); if (isset($_POST['submit'])) { mysql_connect("localhost", "----", "----") or die(mysql_error()); mysql_select_db("members") or die(mysql_error()); $new_age_race = $_POST["age_race"]; $new_contact = $_POST["contact"]; $new_name = $_POST["name"]; $new_non_member = $_POST["non_member"]; $query = "UPDATE `user_settings SET `name` = '{$new_name}' SET `contact` = '{$new_contact}' SET `age_race` = '{$new_age_race}' SET `non_member` = '{$new_non_member}' WHERE id = '{$id}'"; mysql_query($query); echo 'done'; }
-
NEVERMIND-- SOLVED the error i am getting is this: Parse error: syntax error, unexpected $end in C:\xampp\htdocs\change_settings.php on line 29 <?php include("include/topmenu.php"); function sql_quote($data) { if (get_magic_quotes_gpc()) { $data = stripslashes($data); } return addslashes($data); } $id = sql_quote($_GET['id']); if (isset($_POST['submit'])) { mysql_connect("localhost", "*****", "****") or die(mysql_error()); mysql_select_db("members") or die(mysql_error()); $new_age_race = $_POST["age_race"]; $new_contact = $_POST["contact"]; $new_name = $_POST["name"]; $new_non_member = $_POST["non_member"]; $query = "UPDATE `user_settings SET `name` = '{$new_name}' SET `contact` = '{$new_contact}' SET `age_race` = '{$new_age_race}' SET `non_member` = '{$new_non_member}' WHERE id = '{$id}'"; mysql_query($query); echo 'done'; ?> <br> <br> <?php include ("include/footer.php");?> THIS IS LINE 28, THERE IS NO LINE 29
-
what does this: SET `itemnum1` = $_GET['1'] do?
-
i am using the code below to allow the height to stretch the length of the page. Its works great on IE, but why won't it won't on firefox? It stops at the end of the browser... in other words, it won't scroll down. it just stops. <div style="background-color:#C0C0C0;overflow: hidden; width:920px;height:100%">
-
maybe i'm on the wrong interface... a screenshot is attached [attachment deleted by admin]
-
ok. nevermind. i found it. but where on the intereface would i go to forward a port?
-
sorry if i sounds really stupid... i'm really new at this..... This is on my computer... windows vista... From google, it said "A router is a computer whose software and hardware are usually tailored to the tasks of routing and forwarding" I have a linksys home wireless router... is that could be used... i remember what interface you are talking about... but i can't remember the ip address of it, and those two you gave aren't working.
-
like.... what software would i need to download to use to do that?
-
um... anyone know any really good tutorials for that?
-
i don't think so. Unless the installation did it automatically, then no. How do i do that? -Thanks!!!!
-
yes. apache is on Port 80. This is a world-wide domain name, if thats what your asking... i want you to be able to type in my domain name and see it. Not just from my computer, but from everywhere. the domain name is: www.kyforobama.com