Free Web Hosting Forum
(#1 (permalink))
Old
Member
fuadsathar is on a distinguished road
 
Posts: 31
Join Date: Feb 2012
Unhappy I want to create a registration form page - 02-08-2012, 07:20 PM

I want to create a registration form page in my website. Its a website about a group of friends. I have created tables under the names 'id, name, DOB, country, email, account permission and email activation' and now what is the next procedure. Can any help me by giving the correct html code for the registration form and also with the submit button. Also can anyone tell me what happen happens after clicking the submit button.

Waiting for reply

Thank you

Last edited by d3iti; 02-09-2012 at 07:59 AM. Reason: Title does not respect the forum rules
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
Senior Member
Firebirds is on a distinguished road
 
Posts: 252
Join Date: Feb 2012
Default 02-08-2012, 10:50 PM

Ok.
This is a really flexible, open-ended tutorial.
Enclose your form with a <p>. Then,
You start with the <form action="registration.php" method="post">
For every form, do some thing like
HTML Code:
<label for="email">Email: </label>
	      <input type="text" name="email"><br/>
And for the little *****'s for password, do this:
HTML Code:
    <label for="password">Password: </label>
	      <input type="password" name="password"/><br/>
Just replace email with all the other info.
Once you're done, make a submit button.
HTML Code:
<input type="submit"/>
Now, this is really important. Make another php page nammed registration.php exactly, or whatever you put in action=.
Now, you're gonna have to learn a little bit of PHP. But for now, you're ok, I guess.

You start your PHP document like this.
PHP Code:
<?php
On the next lines, you need the php code to take in the information the form just sent out.
This is done using $_POST.
This is how it's used:
PHP Code:
<?php
$email 
$_POST['email'];
Change $email to whatever you need on your form.
BE CAREFUL! make sure the text you put inside the brackets for $_POST EXACTLY matches up with the name of the text element on your form.

Now, you need to check the information that you just got and see if it already exists, or if it is blank.
This is checking if it's blank.
PHP Code:
if ($email == null ||$password == null//add more tests as needed.
{
die(
"You must fill out everything on the form!");
}
else
{
//continue...

So || in php means "or". If just one of the values is null, or nothing, the php script quits and tells the applicant.

In the else bracket, you want to first establish a connection with you sql database. In order to do this, you need your sql hostname, username, and password. This is how to establish a connection.
PHP Code:
$con mysql_connect($host,$username,$password);
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }
else
{

Remeber! You want this to be in between the brackets of the first else{}
Replace $host, $username, and $password with whatever your mysql login info is.
Now, you want to point your code to the right database. This is done like this. This comes in between the second else{}.
PHP Code:
mysql_select_db("login",$con); 
Again, replace "login" with whatever your database is named.
Now, we test if the info, such as email, has been already registered. So first, we query the email address from the database, and if it returns anything but a null, it has already been registered.
PHP Code:
//This comes AFTER the select db function.
$alreadyexists mysql_query(SELECT password FROM login WHERE email $email); //tries to search for the email
if ($alreadyexists != null)  //sees if the email is already in the database.
{
die(
'This email has already been registered. Please use a different email.');

Hopefully, you see how that little snippet works.
Nextly, since everything is going great, we are going to take all the info the user submitted and plug it into the table.
PHP Code:
mysql_query("INSERT INTO Persons (email,password)
VALUES ($email,$password)"
); 
Do this with all the information. Hopefully you made your table so all the columns accept 'varchar'. That is going to be vital. Now, go back into your database and see if it inserted correctly. If you need further help, PM me or go to www.w3schools.com . Thanks and good luck


All your problems magically solved.
How to use custom domain. | Account under review? | Can I do this/whatever?
Have a happy magical day
~Firebirds
Reply With Quote
(#3 (permalink))
Old
Member
fuadsathar is on a distinguished road
 
Posts: 31
Join Date: Feb 2012
Default 02-09-2012, 07:54 AM

I dont need the password section bro. I just need the 'name, DOB, country, email', thats it..... How do i execute this.... and when submitting I want the sender to receive email activation also...
Reply With Quote
(#4 (permalink))
Old
Senior Member
Firebirds is on a distinguished road
 
Posts: 252
Join Date: Feb 2012
Default 02-09-2012, 03:33 PM

You use the Mail() for email activation. So the basic idea is mail($to, 'subject', 'message with link. '.$activationcode.
Then you make a separate form to type the activation code into. When the account is getting created, you want to generate an activation code.


All your problems magically solved.
How to use custom domain. | Account under review? | Can I do this/whatever?
Have a happy magical day
~Firebirds
Reply With Quote
(#5 (permalink))
Old
Member
fuadsathar is on a distinguished road
 
Posts: 31
Join Date: Feb 2012
Default 02-09-2012, 06:27 PM

can u send me the whole script plsss
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com