Qbart Posted January 21, 2007 Share Posted January 21, 2007 Hello,I'm very new to php and mysql. I've just created a domain and a linux host account at goddady.com. I have created a simple database with a table that has valid email addresses that I have confirmed that are from people that will be allowed to register. What I would like to do is be able to have a form on my homepage that will give the user two choices, one login or two register. Before they register though they have to enter their email address, if the email address matches one in the table they will be allowed to register. If not then they will have to email me to validate their email address and I'll manually enter it into the table, then they can register.How would I do this? I'm pretty sure I can handle the basic registration script its the one that checks the table for a valid email address first that I'm having a problem with.Any and all help will be greatly appreciated.Thanks in advance.Q Link to comment https://forums.phpfreaks.com/topic/35060-newbie-question/ Share on other sites More sharing options...
pocobueno1388 Posted January 21, 2007 Share Posted January 21, 2007 First you would search for the email they submitted in the database then check if it is there.[code]<?php$email = $_POST['email'];$email_search = mysql_query("SELECT email FROM table WHERE email='$email'");$num = mysql_num_rows($email_search);if ($num >= 1){ echo "This email is in the database! Feel free to register";} else { echo "This email is not in the database. You are not allowed to register";exit;}?>[/code]Is this what you wanted? Link to comment https://forums.phpfreaks.com/topic/35060-newbie-question/#findComment-165461 Share on other sites More sharing options...
Qbart Posted January 21, 2007 Author Share Posted January 21, 2007 Yes it is, thank you. One quick question, instead of:if ($num >= 1){ echo "This email is in the database! Feel free to register";Instead of telling them they are free to register I would like them to be forwarded to the registration page.Thanks again. Link to comment https://forums.phpfreaks.com/topic/35060-newbie-question/#findComment-165475 Share on other sites More sharing options...
trq Posted January 21, 2007 Share Posted January 21, 2007 [code=php:0]if ($num >= 1) { header("location: register.php");}[/code] Link to comment https://forums.phpfreaks.com/topic/35060-newbie-question/#findComment-165477 Share on other sites More sharing options...
Qbart Posted January 21, 2007 Author Share Posted January 21, 2007 Perfect! Thanks to both of you for the quick response!Qbart Link to comment https://forums.phpfreaks.com/topic/35060-newbie-question/#findComment-165480 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.