Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
First off hello,
Ok, I’m new to mysql and php. I’m trying to create a registration form. I already have it to where the use can submit information. But I would like a way that they could review that information from my mysql database. I created a simple one to test. The database has 4 fields in it, first_name, last_name, email, and pass. I know there has to be a way that I can let the user type in there email and password and view just there information, not every ones. I have tried many different things and failed many times. Any help would be appreciated.
Thanks
Aaron

As a basic test, how about
$res = mysql_query("select * from tbl_name where email='" . $_POST["email"] . "' and pass='" . $_POST["pass"] . "' limit 1;") or die(mysql_error()); if(mysql_num_rows($res) == 1) { while($row = mysql_fetch_assoc($res)) { foreach($row as $key => $val) { echo $key . " = " . $val . "<br>"; } } }You'd need to check the $_POST vars for valid input first and such, but hopefully, the above will work for you.
HTH

Im getting these error messages:
Notice: Undefined index: email in C:\wamp\www\lookatme.php on line 16
Notice: Undefined index: pass in C:\wamp\www\lookatme.php on line 17
email and pass are the variables of my text boxes from the form. Thats what goes after post right?
Heres the HTML code for my form:
<h2>View Registration info</h2>
<FORM ACTION="view.php" METHOD="get" NAME="contact_form">
<TABLE>
<TR>
<TD>Email:</TD>
<TD> <input name="email" type=text id="email" size="30" maxlength="20"></TD>
</TR>
<TR>
<TD>Password:</TD>
<TD><input type=password name="pass" id="pass"></TD>
</TR>
<TR>
<TD><input type="submit" value="Go" name="view" id="view"></TD>
<TD><input type="reset" value="Reset" name="Reset"></TD>
</TR>
</TABLE>
</FORM>So, after $_POST you had it right. I just leave them email and pass right?

Thanks for your help, shutat.
I'm slow but I figured it out now!
I really appreciate you taking the time to help me.
again, Thanks
Airun

Hello; I didn't realize you were using the get method. If you're able to use the post method, then I strongly encourage you to use it instead. With get, anything visitors submit appears as a query string upon submission, shows up in server logs, and can be cached.
If you have to use get, change $_POST to $_GET["email"] and $_GET["pass"]. $_GET itself is usually set when you submit something, so you'd want to check your vars for being empty.
<?php if(!empty($_GET["email"]) && !empty($_GET["pass"])) { // check the database } else { ?> put form code here <?php }?>Hope that helps.

Awesome!!!
That did it!
And your way so much more simpler than the other way my friend try to show me.
Thank a bundle.
I really appreciate it.thank you
Airun

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |