PHP - Invitation!
Hey! I'm really stuck on my for fun project...
What it's supposed to do is quite obvious, grab an invitation code, check if it's created in the database: If it is it'll let you continue, if not it'll redirect you somewhere else, and it works great but I have two problems. The first problem I have is how to stay on the page if it reloads (like if I get the error "you need to fill out all forms" it'll reload) but when it reloads, the saved invitation code that I grabbed previously will be gone and it'll redirect to someplace, which... I don't want to happen! I tried using sessions to save your code but a user can just open the page several times and it'll create multiple sessions and he can therefore register multiple accounts when only one is meant to be registered or something, I'm kind of confused on this stage. Secondly I want to save the code used to register with in a table but this wont work, IDK why but it just won't. <?php include("connect.php"); $invite = $_GET['code']; $validate_invite = mysql_query("SELECT XX FROM XX WHERE invite = '$invite'"); $rows = mysql_num_rows($validate_invite); if($rows>0) { } else { header('Location: /someplace'); } ?> <?php include("include/header.php"); ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="register"> <input type="text" name="email"> username <input type="text" name="username"> password <input type="text" name="password"> <input type="submit" name="submit" value="register"> </form> <?php if (isset($_POST['submit']) ) { $email = mysql_real_escape_string($_POST['email']); $username = mysql_real_escape_string($_POST['username']); $password = $_POST['password']; if (!$email || !$username || !$password) { echo 'you need to fill out all forms'; exit (); } $register_query = 'insert into XX (username, password, email, invite) values("'.$username.'", "'.md5($password).'", "'.$email.'", "'.$invite.'"'; mysql_query($register_query); } ?> If someone would care to help me out I would be very happy, I know I explained it kind of complicated and confusing but you get the point, hopefully. I love you phpfreaks:) Similar TutorialsI am looking for a script that is used in Facebook. Wherein, user enters the email address and password and the system will automatically fetch the addresses from the address book of Hotmail or Gmail etc and sends invitation to join the site network. Do you have any link for such a script that comes free. Looking forward to that. Thanks, Faisal |