# MySQL Not Getting Data from PHP

**URL:** <https://forum.kirupa.com/t/mysql-not-getting-data-from-php/256958>\
**Category:** programming\
**Created:** [April 9, 2008, 3:23am UTC](https://forum.kirupa.com/t/mysql-not-getting-data-from-php/256958 "2008-04-09T03:23:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ximenao](https://avatars.discourse-cdn.com/v4/letter/x/eada6e/32.png) [@Ximenao](https://forum.kirupa.com/u/Ximenao)\
**Post date:** [April 9, 2008, 3:23am UTC](https://forum.kirupa.com/t/mysql-not-getting-data-from-php/256958/1 "2008-04-09T03:23:43Z")

</div>

:sigh: Sigh, here goes…  
I’m doing a basic PHP User Authenticaton system, using the following registration code:

- \<?php  
// Connects to your Database  
mysql\_connect(“[your.hostaddress.com](http://your.hostaddress.com)”, “username”, “password”) or die(mysql\_error());  
mysql\_select\_db(“Database\_Name”) or die(mysql\_error());

//This code runs if the form has been submitted  
if (isset($\_POST[‘submit’])) {

//This makes sure they did not leave any fields blank  
if (!$\_POST[‘username’] | !$\_POST[‘pass’] | !$\_POST[‘pass2’] ) {  
die(‘You did not complete all of the required fields’);  
}

// checks if the username is in use  
if (!get\_magic\_quotes\_gpc()) {  
$\_POST[‘username’] = addslashes($\_POST[‘username’]);  
}  
$usercheck = $\_POST[‘username’];  
$check = mysql\_query(“SELECT username FROM users WHERE username = ‘$usercheck’”)  
or die(mysql\_error());  
$check2 = mysql\_num\_rows($check);

//if the name exists it gives an error  
if ($check2 != 0) {  
die(‘Sorry, the username ‘.$\_POST[‘username’].’ is already in use.’);  
}

// this makes sure both passwords entered match  
if ($\_POST[‘pass’] != $\_POST[‘pass2’]) {  
die('Your passwords did not match. ');  
}

```
// here we encrypt the password and add slashes if needed
$_POST['pass'] = md5($_POST['pass']);
if (!get_magic_quotes_gpc()) {
	$_POST['pass'] = addslashes($_POST['pass']);
	$_POST['username'] = addslashes($_POST['username']);
		}

```

// now we insert it into the database  
$insert = “INSERT INTO users (username, password)  
VALUES (’”.$\_POST[‘username’]."’, ‘".$\_POST[‘pass’]."’)";  
$add\_member = mysql\_query($insert);  
?\>

\<h1\>Registered\</h1\>  
\<p\>Thank you, you have registered - you may now login\</a\>.\</p\>\*

- \<?php  
}  
else  
{   
?\>

\<?php  
}  
?\>\*

Whenever I test it however, even though it says “Registered”,  
no data has been inserted  
I know this because I checked phpmyAdmin for one,  
and also the login page will report: “That user does not exist in our database.”

Can anyone give me the slightest clue of what I’m doing wrong?
