Created
November 6, 2015 10:12
-
-
Save GedMullen/2dd45563a6e13f4be7f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$username = $_POST["uname"]; | |
$password = $_POST["pword"]; | |
$con = mysqli_connect("localhost", "student", "", "ryan04"); | |
//check connection | |
if (mysqli_connect_errno()) { | |
echo "Failed to connect to MySQL: " . mysqli_connect_error(); | |
} else { | |
echo "connected <br />"; | |
$sql = "SELECT * FROM users WHERE name='$username'"; | |
$res = mysqli_query($con, $sql); | |
$numrows = mysqli_num_rows($res); | |
if ($numrows == 0) { | |
$sql = "INSERT INTO users VALUES ('$username', '$password')"; | |
mysqli_query($con, $sql); | |
$form .= "User successfully created.<br />"; | |
$form .= "<a href='login.php'>Click here to go to login</a>"; | |
} else { | |
$form .= "<p>User already exists, please try another Username.</p>"; | |
$form .= displayForm(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment