PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
sirrusdi
Forum Newbie
Posts: 12 Joined: Thu Nov 14, 2002 7:40 pm
Location: Seattle, WA
Post
by sirrusdi » Fri Dec 13, 2002 5:52 pm
I need help fast! The site is going live in two days and i have a big problem. I have built a log-in script that works but i want to allow the user to change their password and email address. Below is the code but it doen't work.
Code: Select all
<?php
include 'db.php';
session_start();
$first_name = $_SESSIONї'first_name'];
$last_name = $_SESSIONї'last_name'];
// Current Settings
$query = "SELECT first_name, last_name, email_address, username, password, last_login FROM users WHERE first_name = '$first_name'";
$result = mysql_query($query);
$query_data = mysql_fetch_array($result);
$password = $query_dataї"password"];
$email = $query_dataї"email_address"];
if ($submit) {
// Updated Settings
$new_password = $_POSTї'new_password'];
$new_email = $_POSTї'new_email'];
if($new_passowrd) {
mysql_query("UPDATE users SET password='$new_password' WHERE first_name='$first_name'");
echo "<center><font color='red'>Password Updated.</font></center>";
setcookie("EwaldGroup_Password", $password, time()-9999);
}
if($new_email) {
mysql_query("UPDATE users SET email_address='$new_email' WHERE first_name='$first_name'");
echo "<center><font color='red'>Email Address Updated.</font></center>";
}
}
?>
Thanks for your help!
-Michael Ewald
JPlush76
Forum Regular
Posts: 819 Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:
Post
by JPlush76 » Fri Dec 13, 2002 6:11 pm
what doesn't work about it? getting errors? not submitting to the database? not reading the form values?
kitsch
Forum Newbie
Posts: 12 Joined: Mon Nov 11, 2002 3:29 pm
Post
by kitsch » Fri Dec 13, 2002 6:13 pm
We all have big problems.
At the beginning of your script insert these:
Code: Select all
$submit = $_POSTї'submit'];
$new_password = $_POSTї'new_password'];
$new_email = $_POSTї'new_email'];
And whatever else is coming from your form. I hope you receive it by the post method...
You also have a typo here:
I think you meant new_password...
sirrusdi
Forum Newbie
Posts: 12 Joined: Thu Nov 14, 2002 7:40 pm
Location: Seattle, WA
Post
by sirrusdi » Fri Dec 13, 2002 9:15 pm
Thanks Guys! It works!