blamoi Posted April 7, 2013 Share Posted April 7, 2013 Hi everybodycan someone help me to make an email validtion system in my code, and help me find a way to check if the username is taken, and if possible where i should put the code in, im new in this and i find it very hard Here is my registration site <?php session_start();session_destroy(); session_start(); if($_GET["Brugernavn"] && $_GET["Email"] && $_GET["Password1"] && $_GET["Password2"] ) //tjekker alle data { if($_GET["Password1"]==$_GET["Password2"]) //Her tjekker jeg at begge indtastede password er ens { $Server="localhost"; $Brugernavn="root"; $conn= mysql_connect($Server,$Brugernavn)or die(mysql_error()); mysql_select_db("test",$conn); //Her opretter jeg en forbindelse til databasen $sql="insert into Brugere (Brugernavn,Email,Password)values('$_GET[brugernavn]','$_GET[Email]','$_GET[Password1]')"; //Her indsætter jeg de indtastede værdier ind i tabellen i min database $result=mysql_query($sql,$conn) or die(mysql_error()); echo "<h1>Du er nu blevet registreret</h1>"; //Hvis alt passer kommer teksten "Du er nu osv." frem echo "<a href='Startside.php'>Gå til startside</a>"; //Hvis alt passer kommer der et link der sender brugeren til startsiden } else echo "Passwordende passer ikke sammen, prøv igen"; //Hvis passwordne ikke passer, udskriver jeg teksten "Passwordende passer osv." } else echo"Data er fucked"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/276653-email-validation-and-username-check/ Share on other sites More sharing options...
ra_ie_darkness Posted April 8, 2013 Share Posted April 8, 2013 To validate email you can use filter_input() $email = filter_input(INPUT_GET,'email',FILTER_VALIDATE_EMAIL); You can check the username by sending a query to the database mysql_num_rows will return the number of rows containing the username. $q = mysql_query("Select * from table where username='$username'"); if(mysql_num_rows($q)!=0) { echo "Username exists"; } Quote Link to comment https://forums.phpfreaks.com/topic/276653-email-validation-and-username-check/#findComment-1423523 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.