Saturday, 28 September 2013

How do I create a registration, login/logout form, and a profile page for users in php

How do I create a registration, login/logout form, and a profile page for
users in php

I've asked questions before on how to connect to the database using
000webhost, I've failed many times on connections and what not. I need
some help on creating a sign up form and email verification and a
login/logout form. I am a beginner web developer, should I switch to a
different hosting provider because all the creditials for 000webhost are
to complicated and I just want a simple database connection that would
actually work for me. What hosting provider should I switch too? Here's my
code I am having trouble with connecting to the database:
<?php
$email = $_POST['email'];
if ($email == null) //add more tests as needed.
{
die("You must fill out everything on the form!");
}
else
{
//continue...
}
$username = $_POST['username'];
if ($username == null) //add more tests as needed.
{
die("You must fill out everything on the form!");
}
else
{
//continue...
}
$password = $_POST['password'];
if ($password == null) //add more tests as needed.
{
die("You must fill out everything on the form!");
}
else
{
//continue...
}
$connect = mysql_connect (
$host = $mysql#.000webhost.com;
$dbuser = $#####_#####;
$dbpass = $########;
$db = $#####_######;
$siteurl = http://#######.site90.com/;
$sitemail = autoresponder@#####.site90.com;
$domain = http://#########.site90.com/;
)
if (!$connect)
{
die('Could not connect: WHAT THE FUCK ' . mysql_error());
}
else
{
mysql_select_db('######_#####', $connect);
$alreadyexists = mysql_query("SELECT password FROM tbl_users WHERE
email = $email");
if ($alreadyexists != null)
{
die('This email has already been registered. Please use a different
email.');
}
$alreadyexists = mysql_query("SELECT password FROM tbl_users WHERE
username = $username");
if ($alreadyexists != null)
{
die('This username has already been registered. Please use a different
username.');
}
mysql_query("INSERT INTO Persons (username,email,password)
VALUES ($username,$email,$password)");
}
?>

No comments:

Post a Comment