View Single Post
Old 02-14-2008, 12:42 AM   #12 (permalink)
StevenF
The Contributor
 
Join Date: Jan 2008
Posts: 87
Thanks: 49
StevenF is on a distinguished road
Default

I don't know what was wrong there, but I seemed to have fixed it!

I didn't know that addslashes and mysql_real_escape_string() weren't to be used together. Thanks for letting me know!

I am getting somewhere now, I have the following:
Code:
<?php

	//Database Structure
		//Setting username and password
		$username="";
		$password="";
		$database="scotlandbands";

		mysql_connect($localhost, $username, $password) or die ('<strong>MySQL Error:</strong>'.mysql_error());
		mysql_select_db($database) or die ('<strong>MySQL Error:</strong>'.mysql_error());
		
	
	//setting variables 
	$reg_username = ($_POST['reg_username']);
	$reg_email = ($_POST['reg_email']);
	$reg_password = md5($_POST['reg_password']);
	
	//creating a query that inserts the data into the database
	$query = 'INSERT INTO users SET		user_name = "'.mysql_real_escape_string($reg_username).'",
										email = "'.mysql_real_escape_string($reg_email).'",
										user_pass = "'.mysql_real_escape_string($reg_password).'"';
	
	//execcute a query on a MySQL database
	mysql_query($query);
	
	//close database connection
	mysql_close();

?>
Hope that's more readable now!

Now, when I try to enter a username and password which is stored in the database, I'm being taken to login.html - which means the login was not successful. I don't know why this is happening, because I'm entering the correct details.
__________________
My Personal and Photo Blog
StevenF is offline  
Reply With Quote