Hello

I read sessions and php but it's not exactly registering in my head that I understand it easily. On my site someone signups all is good they get their email and register sign in.

I have them signup with a Desired Username, Email address and Password okay. Now when they come back to sign in all that is required is their Email address and Password and I want them to be greeted once in by their desired username.

It is doing it but only keeping the first desired username, it doesn't register the new user it only keeps listing the 1st persons username. If you know what I should do I'd be really grateful! This is what I have

<?
include 'db.php';


// get the variables from home page
$password = $_REQUEST;
$email_address = $_REQUEST;


$sql_check = mysql_query("UPDATE members WHERE password='$password' AND
email_address='$email_address'");
$sql_check = mysql_query("SELECT * FROM members WHERE
password='$password' AND
email_address='$email_address'");


$SQL="SELECT * FROM members";
$RESULT=mysql_query($SQL);


//Get the result:
$username=mysql_fetch_array($RESULT);


$sql_check_num = mysql_num_rows($sql_check);
if($sql_check_num == 0){



//Display it:


echo ("<STRONG>You must be a member!</STRONG>");
} else {
echo ("Welcome")," ", $username["username"];
}


?>

$sql_check = mysql_query("UPDATE members WHERE password='$password' AND
email_address='$email_address'");

Where is your comand to update. You have the update command but not SET command to tell it what to update and how. You have it getting the tuples (records) but not updating anything. it should read

UPDATE members SET (the update) WHERE password='password' AND email_address = '$email_address'"


also unless you are skipping pieces in your code why are you fetching the array if you are never using it. You might have left it out but a couple of your variable stores don't look to have a point.

however as far as only giving the FIRST name thats because that's all your calling. The mysql_fetch_array() only returns the array ONE row at a time. You would need to use it in a loop to get it to show them all at once.

while ($username = mysql_fetch_array($results))
{

}

This will give you all the arrays and exit when $username goes NULL or EOF at the end of the results list. Its a VERY powerful command for things like that.

Thanks for your reply , I am trying to still understand this and I should of added in i am trying to call the username of the email_address and password user that is in the database.

Now when they just signin not signup they only now need to enter their password and email_address and I have my request like this:

<?
include 'db.php';

// get the variables from home page
$password = $_REQUEST;
$email_address = $_REQUEST;

$sql_check = mysql_query("UPDATE members SET (the update) WHERE password='password'
AND email_address='$email_address'");
$sql_check = mysql_query("SELECT * FROM members WHERE password='$password' AND
email_address='$email_address'");


$sql_check_num = mysql_num_rows($sql_check);
if($sql_check_num == 0){

echo ("<STRONG>You must be a member!</STRONG>");
} else {
echo ("Welcome")," ", $username["username"];
}

?>

Because the form is only taking their email and password if I request username it is not working, My question is how can I get their username to Post and say Welcome to them with their username - how do i query and get their username to Post! I would be so happy if you could tell me, Thanks!

if all you're doing is retrieving the data you don't need the UPDATE command at all. Just the select query. You can also save some trouble by writting the select query to return only the Username but its not necessary.

SELECT username FROM members WHERE password='$password' AND
email_address='$email_address'


also to get the data from the results you have to parse the results in your case $sql_check into an array which I'll call username for your ease.

$username = mysql_fetch_array($sql_check, MYSQL_ASSOC); //MYSQL_ASSOC allows you to use the colomn name to reference it. Most default allowing index numbers and this. But I find it easier to tell it to make it this way so as to not have errors if I have to move my code.

then your echo would look like this.

echo 'Welcome '.$username;

That would output Welcome and then the user neme.

Hope that helps.

You are a very nice person DGStudios

Thank-you so much you really made my day a big happy difference for me. I told my family and friends’ today “Good people do still exist in the world - I was referring to you! That was super of you!

I never thought to eliminate the update code and for the second part - I never seen a code like that so, I’d of not figured it out. I am so grateful to you really thanks a lot!
I am now closer to finishing my site.

The user is in and the address bar is perfect! It just shows the page as it should
www.puddinpatchdatematch.com /welcome.php - and the user can go back and forth without getting an error page - Thanks to you!

So I only now need to figure out how:

1) Again now that the user is in - When they click on any of the links like: your picture gallery or create your profile etc… The page has to come in without the address bar changing.

The address bar has to stay the same – mate1 uses this format how I do not know but it seems like a very safe neat and tidy format to use. The Welcome username is always displayed and the user is clearly in their account. It’s personalized I love it!

I do have it working thank goodness - That if the user is logged in and saves the page to their favourites - When they later link in again - It opens displaying they must login or signup. - It does not open displaying they are - logged in - as they saved it.
So that is working. Nice!

1) So I need to get the links coming in like I just explained
2) I need to know - how the user can upload their pictures
3) I need to know - how to create a search engine (My server offers something on this
I must research that more)
4) I need the site to work on all or as many browsers as possible.
5) I need to know - how to backup my database…

6) And I need it to work so all the users’ information is stored in the database and can be retrieved to the users account from the database - Including their pictures … I think I can figure out how to do that part. “The pictures intimidate me a bit because I do not know about that at all.

Than I believe I will be ready…To be an Online Professional Dating Site.
Have a nice Passover or Easter holiday DGStudios, Thanks again Puddin

P.S - I just included what I have left in case any help can be offered… If you cannot I understand and As far as becoming my own server... If you’re referring to (IIS) is that what you mean.

I did attempt using Internet Information Services (IIS) I spent a lot of time on it - it was hard I was using asp and got mysite up but my computer kept messing up I was scared – I obviously was not doing somethings right – it was a Hugh job restoring and uninstalling and installing what a time I had I was so stressed I said okay pass on this for now.

I'll have to see in the future it was very difficult. That is when I gave up and went with the server. In all they have been really nice. I think they run into problems to maybe staff quit things get messed up… I have my files backed up. They have a phone number are professional and answer by phone and email quickly I like that – I also have become to know a lot of the staff who answer the phones so that is better too. My server is internic.ca

You are very welcome, I am currently writing the code by hand for a forum so I've come to find alot of strange errors. Its nice to see that I was able to help someone. As with most geeks, I have confidence issues and it helps to be thanked. As for the help on other things. I'm a personal opinion that everything has to look and work correctly before I move on. I looked at the link you left and the layout is very hard to read and some bad overlap issues need to be delt with. It'd be hard to explain how to fix without code. I would love to help with that if I can.

The other parts I'd be happy to help with, PM me and I will try to help if I can. I haven't had too much exp. with the uploading images and things into the DB however I can look at things in the book I have and trying to find it. the many browser issue isn't as big a deal as you would think until you start working with things like CSS where each one requires aditional code to allow it to work on other browsers. Sadly these would have to be almost completley individually looked up.

I'd have to look it up but I do believe that forms have the abiltiy to have data that is entered as invisible and so can be passed I believe as postdata thuse not changing the address bar at all. Most of the work I do while staying int he same page uses php passed veriables that do show in the address bar. this is also somehting I'd have to look up in my dynamic pages book.

Hi DGStudios,

I think hope you are seeing it poorly because of the browser - it is working on Internet explorer browser. I will figure out the different browsers for sure. So far Internet explorer browser seems Fine. I think you had a look from a different Browser! It has to be...

I will also look for that book! Is that the name dynamic pages. Like i'm going back to a few libraries this week! Good luck with what you are doing, Cheers!

I'm using Firefox. So that could be the reason. I don't usually use Stylization because it is browser specific. The Title of the book is.

PHP and MYSQL for Dynamic web Sites by Larry Ullman.

Its the book I use.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.