Jump to content

Recommended Posts

Hi everybody
can 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  smile.png
Here is my registration site smile.png

 

<?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";

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/276653-email-validation-and-username-check/
Share on other sites

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";
}
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.