#1 (permalink)  
Old 01-12-10, 06:17 PM
murugaperumal.s murugaperumal.s is offline
Newbie Coder
 
Join Date: Jan 2010
Posts: 9
Thanks: 5
Thanked 0 Times in 0 Posts
Smile Php

Hai friend,

I need your help. i am beginer of php. In my question "how to store the information php form to database mysql.
Reply With Quote
  #2 (permalink)  
Old 01-12-10, 08:27 PM
ruteckycs's Avatar
ruteckycs ruteckycs is offline
Coding Addict
 
Join Date: Jul 2009
Posts: 377
Thanks: 6
Thanked 10 Times in 10 Posts
Thats a fairly general question ... however here is a good MYSQL / PHP tutorial. I suggest you read it and try the sample codes.
MySQL Tutorial - Introduction
__________________
This post was created with 100% recycled electrons.
Reply With Quote
The Following User Says Thank You to ruteckycs For This Useful Post:
murugaperumal.s (01-15-10)
  #3 (permalink)  
Old 01-13-10, 11:46 AM
murugaperumal.s murugaperumal.s is offline
Newbie Coder
 
Join Date: Jan 2010
Posts: 9
Thanks: 5
Thanked 0 Times in 0 Posts
Spin php

I tried in this code. But in this showing error notice "undefined index: submit". Please give a solution for in this.

<html>
<body>
<form method="post" action="edit.php">
<b>username:</b>
<input type="text" name="username" size="40">
<br>
<b>phone:</b>
<input type="text" name="phone" size="10">
<br>
<input type="submit" name="submit" value="sign!">
<input type="startover" name="restart" value="tryagain">
</form>
</body>
</html>
<?php
/* dbconnect.php as a database connection file */
include("dbconnect.php");
if($_REQUEST["submit"] == "submit")
{
$query="insert into test(username,phone) values ('".$_REQUEST['username"]
."','".$_REQUEST['phone"]."')";
mysql_query($query)
}
?>
Reply With Quote
  #4 (permalink)  
Old 01-13-10, 01:53 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by murugaperumal.s View Post
I tried in this code. But in this showing error notice "undefined index: submit". Please give a solution for in this.
You can ignore this error for the moment, it just means that you didn't initialize the variable REQUEST['submit'].

This code should NOT be used in a web-facing environment, as it doesn't screen or sanitze any of the input variables pulled from the REQUEST[] array. If you run this code as-is, your site or server will very likely be hacked.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
The Following User Says Thank You to End User For This Useful Post:
murugaperumal.s (01-14-10)
  #5 (permalink)  
Old 01-14-10, 11:54 AM
murugaperumal.s murugaperumal.s is offline
Newbie Coder
 
Join Date: Jan 2010
Posts: 9
Thanks: 5
Thanked 0 Times in 0 Posts
Spin Php

I cann't store the information form to database. I need the solution for this. In my request How to store the value Form to the Database (HTML FORM TO MYSQL)?
I am working in WAMP.

<html>
<body>
<form method="post" action="edit.php">
<b>username:</b>
<input type="text" name="username" size="40">
<br>
<b>phone:</b>
<input type="text" name="phone" size="10">
<br>
<input type="submit" name="submit" value="sign!">
<input type="startover" name="restart" value="tryagain">
</form>
</body>
</html>
<?php
/* dbconnect.php as a database connection file */
include("dbconnect.php");
if(isset($_REQUEST["submit"]) && submit== "sign!")
{
$query="insert into test(username,phone) values ('".$_REQUEST['username"]
."','".$_REQUEST['phone"]."')";
mysql_query($query);
}
?>
Reply With Quote
  #6 (permalink)  
Old 01-14-10, 12:38 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by murugaperumal.s View Post
I cann't store the information form to database.
You have to give us more information than "I cann't store the information form to database". For example:
  1. What error messages are you seeing?
  2. Is the submitted information making it into the query?
  3. Is anything being stored?
  4. Are you sure you're establishing a database connection?
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
The Following User Says Thank You to End User For This Useful Post:
murugaperumal.s (01-14-10)
  #7 (permalink)  
Old 01-14-10, 12:47 PM
murugaperumal.s murugaperumal.s is offline
Newbie Coder
 
Join Date: Jan 2010
Posts: 9
Thanks: 5
Thanked 0 Times in 0 Posts
I enter the username and phone information in form. It cann't store in the database. After going to see the database it will empty. It wouldn't show any error. I need good solution for this.
Reply With Quote
  #8 (permalink)  
Old 01-14-10, 12:57 PM
murugaperumal.s murugaperumal.s is offline
Newbie Coder
 
Join Date: Jan 2010
Posts: 9
Thanks: 5
Thanked 0 Times in 0 Posts
Thanks for kind reply
I did mistake in your 2nd Question. I didn't grant the submit permission into the Query.
Reply With Quote
  #9 (permalink)  
Old 01-14-10, 02:37 PM
ruteckycs's Avatar
ruteckycs ruteckycs is offline
Coding Addict
 
Join Date: Jul 2009
Posts: 377
Thanks: 6
Thanked 10 Times in 10 Posts
Add

or die(mysql_error());

to the end of you quarry and see if you get an error report.
__________________
This post was created with 100% recycled electrons.
Reply With Quote
  #10 (permalink)  
Old 01-14-10, 05:01 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
PHP Code:

<html>
<body>
<form method="post" action="">
<b>username:</b>
<input type="text" name="username" size="40">
<br>
<b>phone:</b>
<input type="text" name="phone" size="10">
<br>
<input type="submit" name="submit" value="sign!">
<input type="startover" name="restart" value="tryagain">
</form>
</body>
</html>
<?php
/* dbconnect.php as a database connection file */
include("dbconnect.php");
$submitArray = array('sign!');
$submit = (isset($_POST['submit'])) ? $_POST['submit'] : NULL;
if(isset(
$submit) && in_array($submit,$submitArray))
{
$user = (isset($_POST['username'])) ? mysql_real_escape_string($_POST['username']) : NULL;
$phone = (isset($_POST['phone'])) ? mysql_real_escape_string($_POST['phone']) : NULL;
    if(
$user != NULL && $phone != NULL) {
        
$query="INSERT INTO `test`(`username`,`phone`) VALUES ('$user','$phone')";
        
mysql_query($query) or die(mysql_error());
    }
    else {
        echo 
'You must fill in both the Username, and the Phone Number!';
    }
}
?>
Reply With Quote
The Following User Says Thank You to Jcbones For This Useful Post:
murugaperumal.s (01-15-10)
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 10:17 AM
help with error messages.. please APuppyDog PHP 2 10-05-06 11:09 PM
PHP Downside--Solutions? Amulet PHP 10 07-15-05 08:26 AM


All times are GMT -5. The time now is 08:06 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.