good
good
very nice bro very nice:
but here is some problem i 'm using free hosting which is not providing me SQL database. so please can you tell me any script like this but no database require.
urduworld.110mb.com

you can use regular text files instead of database. its not gonna be easy, because you will have to write your own inserting, searching(quires) functions.
the files may look like this:
users.txt
usernameassword
test:testpass
nice!
Hi there
I am totally new to php and i have setup the database and created a user and password. I have seen in the script where i put the username and databse name but i can't see where the password goes. Can anyone help...
Code:<?php
session_start();session_destroy();
session_start();
if($_GET["regname"] && $_GET["regemail"] && $_GET["regpass1"] && $_GET["regpass2"] )
{
if($_GET["regpass1"]==$_GET["regpass2"])
{
$servername="localhost";
$username="root";
$conn= mysql_connect($servername,$username)or die(mysql_error());
mysql_select_db("test1",$conn);
$sql="insert into users (name,email,password)values('$_GET[regname]','$_GET[regemail]','$_GET[regpass1]')";
$result=mysql_query($sql,$conn) or die(mysql_error());
print "<h1>you have registered sucessfully</h1>";
print "<a href='index.php'>go to login page</a>";
}
else print "passwords doesnt match";
}
else print"invaild input data";
?>
Last edited by Orjan; 01-21-2010 at 11:22 AM. Reason: Please use code tags for your code!
@hudbarnett
I don't really get what you're trying to ask, but I'll try to answer.
According to the SQL syntax above, the data from the registration form is inserted to a table named users, which has fields (or columns) named name, email & password.Code:$sql="insert into users (name,email,password) values ('$_GET[regname]','$_GET[regemail]','$_GET[regpass1]')";
$_GET[regname]'s value goes to the name column.
$_GET[regemail]'s value goes to the email column.
$_GET[regpass1]'s value goes to the password column.
Also, if I may enhance that rough code of yours :
Of course, these amendments of mine may not be optimal and/or may contain an error or two, but please do correct me if I'm wrong.Code:<?php
session_start();
session_unset();
if(isset($_GET["regname"],$_GET["regemail"],$_GET["regpass1"],$_GET["regpass2"]))
{
if($_GET["regpass1"] == $_GET["regpass2"])
{
$servername = "localhost";
$username = "root";
$conn = mysql_connect($servername,$username) or die('Could not connect : ' . mysql_error());
mysql_select_db("test1");
$sql = "INSERT INTO `users` VALUES ('$_GET[regname]','$_GET[regemail]','$_GET[regpass1]')";
$result = mysql_query($sql) or die('Could not insert values : ' . mysql_error());
mysql_close();
print "<h1>You have registered sucessfully.</h1><br><br>";
print "Go to <a href='index.php'>login page</a>.";
}
else
print "Passwords don't match.";
}
else
print "Invalid input data.";
?>
Well.. I suggest if you have finished your code, remove those "mysql()" errors because they are good information for hackers![]()
█ Get A Cheap Top Level Domain, COM and NET domains only for $7.95 - Get Yours Now!
█ Trill Hosting - Cheap SSL, Cheap Web Hosting, Register Cheap Domains, Cheap Blog Hosting
█ www.trillhosting.com | support@trillhosting.com
█ Hosting Plans | Write To Us | Support | Client Area | About Us
CodeCall Blog | CodeCall Wiki
@so1i
Ah, so that's what he really meant...
Nothing screws my head more than hours of Dragon Age, I guess... =b
@hudbarnett
Like Jaan said, those die() functions should not contain mysql_error() function anymore if the website is accessible by the public.
It's still fine if you just want to test things out in your own computer, though.
Might as well looking up some techniques in input validation, especially using regular expressions (regex).
i downloaded the attached files for this. when i run registration it says Table 'test.users' doesn't exist.. help me pls..
There are currently 3 users browsing this thread. (0 members and 3 guests)
Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum