Hi , I hve created register form which contains details of
(firstname,lastname,username,password,confirm password,email,confirm email,date of birth,gender,address,state,country.)
So my problem is i have simply registered to this form,there is no database shown of my these filled details where i have create tables in myphpadmin.
So pls say how to send register form filled details of users to database.
Iam using database.
waiting for ur reply.
pls help me
Started by riyazbasha, Feb 05 2010 02:42 AM
8 replies to this topic
#1
Posted 05 February 2010 - 02:42 AM
|
|
|
#2
Posted 05 February 2010 - 07:33 AM
I guess you are using MySQL then.
do you know any SQL?
you need to write a Insert query and send it to your database with the information you want to store.
did this make it clearer to you?
do you know any SQL?
you need to write a Insert query and send it to your database with the information you want to store.
INSERT INTO tablename (fieldname1, fieldname2 [...], fieldnameN) VALUES (value1, value2, [...], valueN)
did this make it clearer to you?
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I study Information Systems at Karlstad University when I'm not on CodeCall
#3
Posted 07 February 2010 - 08:49 AM
I'll assume you are using PHP
First make an HTML Form
Then make a simple php file
First make an HTML Form
<form method="post" action="sql.php"> <input ......> ... <input type="submit" ...> </form>
Then make a simple php file
<?php
$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db');
$firstname = $mysqli->real_escape_string($_POST['firstname']);
/* and the rest */
$country = $mysqli->real_escape_string($_POST['country']);
$mysqli->query("
INSERT INTO tablename (firstname, lastname, ... , country)
VALUES ( '$firstname' , '$lastname' , ... , '$country' )
");
header("Location: http://mydestination.com");
?>
#4
Posted 07 February 2010 - 08:49 AM
#5
Posted 07 February 2010 - 10:02 AM
Hi,
First of all you must be sure of what method (get/post) you are using to submit form(In method attribute i.e,<form method="post" action="yourscript.php" />)
If you are using post method, you can access the data from $_POST[] array. ie, $firstname=$_POST['firstname'].
else you can get it from "$_GET[]" array.
Then you can create a dynamic query using the data you obtained from post or get array.
ie,
$query="insert into foo(firstname) values($firstname)";
then just pass the query to your DB.
Hope this will answer your question.
First of all you must be sure of what method (get/post) you are using to submit form(In method attribute i.e,<form method="post" action="yourscript.php" />)
If you are using post method, you can access the data from $_POST[] array. ie, $firstname=$_POST['firstname'].
else you can get it from "$_GET[]" array.
Then you can create a dynamic query using the data you obtained from post or get array.
ie,
$query="insert into foo(firstname) values($firstname)";
then just pass the query to your DB.
Hope this will answer your question.
#6
Posted 08 February 2010 - 06:33 PM
for that you must make sure you have the right names for your text boxes in your form
a simple example is this
a simple example is this
<?php
mysql_connect('localhost','root','');
mysql_select_db('riyaz');
if($_REQUEST["Send"])
{
$insert = mysql_query("INSERT INTO user_tbl set firstname = '".$_POST['firstname']."',
lastname = '".$_POST['lastname']."'");
# or you could use the other method
$insert = mysql_query("INSERT INTO user_tbl (firstname,lastname) VALUES('".$_POST['firstname']."','".$_POST['lastname']."')");
if($insert) { echo 'Successful'; }
else { echo 'unsuccessfull'; }
}
# note that you must only choose one method i gave not both of them because that will do the query twice!
?>
<form action="" method="post">
<input type="text" name="firstname" size="30">
<input type="text" name="lastname" size="30">
<input type="submit" name="send" value="Send">
</form>
Edited by Orjan, 09 February 2010 - 07:27 AM.
Please use code tags when posting code!
#7
Posted 12 February 2010 - 06:23 AM
you should know how to get the date from the submit, and then , know how to insert into the mysql database .
just like upper reply.
just like upper reply.
#8
Posted 15 February 2010 - 08:14 AM
I think that there is nothing difficult in form contact with the database. There are many correct answers, and primary information can take on PHP form tutorials.
#9
Posted 15 February 2010 - 10:15 AM
As from your descriptions I assume you're using POST methods to send data ( by form input fields ). So an example would be:
Very basic example. However for a more detailed explanation on this, and examples on creating register systems with forms & login systems as well, I'd advice you to have a look at my tutorial about creating a register system - if I'm allowed to reccomend this to you here ;)
Cheers.
<?php
if($_POST['submit']) { //submit button pressed? -> form data sent?
mysql_connect("localhost", "root", "password"); //'host','username','password'
mysql_select_db("database_name"0;
$add_account = mysql_query("INSERT INTO accounts('username', 'password', 'field3')VALUES('".mysql_real_escape_string($_POST['username'])."', '".mysql_real_escape_string($_POST['password'])."', '".mysql_real_escape_string($_POST['user_input_field_3_name'])."') ")or die(mysql_error()); //replace accounts by the name of your table for register results-member accounts
}else{
// ?> ... show your form, in this example user input fields were named 'username' and 'password' <?php
}
?>
Very basic example. However for a more detailed explanation on this, and examples on creating register systems with forms & login systems as well, I'd advice you to have a look at my tutorial about creating a register system - if I'm allowed to reccomend this to you here ;)
Cheers.
Edited by webcodez, 16 February 2010 - 08:25 AM.


Sign In
Create Account

Back to top









