The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> SQL help
mihir
post Feb 3 2013, 03:15 AM
Post #1


Newbie
*

Group: Members
Posts: 10
Joined: 19-December 12
Member No.: 18,285



I have this login system ... http://testmihir.site88.net

It is not working afte changing

I have this code .

<?php

//This function will display the registration form
function register_form(){

$date = date('D, M, Y');
echo "<form action='?act=register' method='post'>"
."Username: <input type='text' name='username' size='30'><br>"
."Password: <input type='password' name='password' size='30'><br>"
."Confirm your password: <input type='password' name='password_conf' size='30'><br>"
."Email: <input type='text' name='email' size='30'><br>"
."<input type='hidden' name='date' value='$date'>"
."<input type='submit' value='Register'>"
."</form>";

}

//This function will register users data
function register(){

//Connecting to database
$connect = mysql_connect("mysql1.000webhost.com", "******", "*******");
if(!$connect){
die(mysql_error());
}

//Selecting database
$select_db = mysql_select_db("*********", $connect);
if(!$select_db){
die(mysql_error());
}

//Collecting info
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
$pass_conf = $_REQUEST['password_conf'];
$email = $_REQUEST['email'];
$date = $_REQUEST['date'];

//Here we will check do we have all inputs filled

if(empty($username)){
die("Please enter your username!<br>");
}

if(empty($password)){
die("Please enter your password!<br>");
}

if(empty($pass_conf)){
die("Please confirm your password!<br>");
}

if(empty($email)){
die("Please enter your email!");
}

//Let's check if this username is already in use

$user_check = mysql_query("SELECT username FROM users WHERE username='$username'");
$do_user_check = mysql_num_rows($user_check);

//Now if email is already in use

$email_check = mysql_query("SELECT email FROM users WHERE email='$email'");
$do_email_check = mysql_num_rows($email_check);

//Now display errors

if($do_user_check > 0){
die("Username is already in use!<br>");
}

if($do_email_check > 0){
die("Email is already in use!");
}

//Now let's check does passwords match

if($password != $pass_conf){
die("Passwords don't match!");
}


//If everything is okay let's register this user

$insert = mysql_query("INSERT INTO users (username, password, email) VALUES ('$username', '$password', '$email')");
if(!$insert){
die("There's little problem: ".mysql_error());
}

echo $username.", you are now registered. Thank you!<br><a href=login.php>Login</a> | <a href=index.php>Index</a>";

}

switch($act){

default;
register_form();
break;

case "register";
register();
break;

}

?>

Please tell me what else to change !
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Feb 3 2013, 11:51 PM
Post #2


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



QUOTE
It is not working afte changing


"...after changing" what??

QUOTE
Please tell me what else to change !


Well, it's your program, you have to debug it. You can't expect someone else to spend hours working out what it is supposed to be doing, and guess what you meant to do. Sorry, you need to ask much more specific questions.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
mihir
post Feb 4 2013, 10:36 AM
Post #3


Newbie
*

Group: Members
Posts: 10
Joined: 19-December 12
Member No.: 18,285



I changed the username , password ,host and databse name .. but it did not gett signed in .
Ok thank you for the advice . I will do it My self !!!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
NomadUK
post Mar 18 2013, 02:26 PM
Post #4





Group: Members
Posts: 3
Joined: 18-March 13
Member No.: 18,864



QUOTE(mihir @ Feb 4 2013, 03:36 PM) *

I changed the username , password ,host and databse name .. but it did not gett signed in .
Ok thank you for the advice . I will do it My self !!!



is it running on the server your sql database is on? if not you will have to allow access to the sql server from a different ip address.

if it is on the same server use "localhost" instead of web address.

I may be wrong with this but this is how mine connects and to get dreamweaver to connect I had to allow my ip address access.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 29th March 2024 - 03:02 AM