Can any one help me in PHP MYSQL

bdweb

New Member
Messages
30
Reaction score
0
Points
0
T1 and t2 is the name of a two text field



Like I created a form in that forum I create a two text field given the name t1 and t2 and a submit button and save it as test.htm



Now I want to get the value of t1 and t2 and put it in the MYSQL database through PHP script.

Or

I want to search the database with the value of t1 and t2 through PHP script



Can any one give me the solution in a simple way it will be great help for me



Thanks in adv
 
B

Brandon

Guest
inSERT inTO I think that may be the command your looking for
 

o0slowpaul0o

New Member
Messages
254
Reaction score
0
Points
0
1) show the script so far.
2) All PHP files should be saved with the exstention of .php.
 
B

binki39

Guest
hope this hopes... after you have created the table to store the values from t1 and t1 textareas in a form, use this to store the values in those 2 variables into the database

mysql_query("insert into NAMEOFYOURTABLE (id, t1, t2) values ('NULL', '$id', '$t1', '$t2')") or die(mysql_error());

the id is just to identify the rows of the table

if you just want to store those 2 values for temporary use, just use define 2 values as follow

variable1 = $_POST['t1'];
variable2 = $_POST['t2'];

i think that might work.
 

warol

New Member
Messages
14
Reaction score
0
Points
0
binki39 said:
hope this hopes... after you have created the table to store the values from t1 and t1 textareas in a form, use this to store the values in those 2 variables into the database

mysql_query("insert into NAMEOFYOURTABLE (id, t1, t2) values ('NULL', '$id', '$t1', '$t2')") or die(mysql_error());

the id is just to identify the rows of the table

if you just want to store those 2 values for temporary use, just use define 2 values as follow

variable1 = $_POST['t1'];
variable2 = $_POST['t2'];

i think that might work.

this NULL value is not necessary
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
warol said:
binki39 said:
hope this hopes... after you have created the table to store the values from t1 and t1 textareas in a form, use this to store the values in those 2 variables into the database

mysql_query("insert into NAMEOFYOURTABLE (id, t1, t2) values ('NULL', '$id', '$t1', '$t2')") or die(mysql_error());

the id is just to identify the rows of the table

if you just want to store those 2 values for temporary use, just use define 2 values as follow

variable1 = $_POST['t1'];
variable2 = $_POST['t2'];

i think that might work.

this NULL value is not necessary

You don't need the "id" in the query either. If you leave it blank, and try to insert a row, it'll automatically insert the id in there.
 

bdweb

New Member
Messages
30
Reaction score
0
Points
0
Thanks and i finaly make it

But When I create a check box in a forum if the user did not select the check box and click submit it shows me,
Notice: Undefined index: php in c:\program files\easyphp1-8\www\webhosting\view.php on line 9

I use this funtion to call the variable from a forum


$php = $HTTP_POST_VARS['php'];

view.php

Which command or fution shall I use for check box
Can any one help me about this

Thanks in adv
 
Last edited:

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
bdweb said:
Thanks and i finaly make it

But When I create a check box in a forum if the user did not select the check box and click submit it shows me,
Notice: Undefined index: php in c:\program files\easyphp1-8\www\webhosting\view.php on line 9

I use this funtion to call the variable from a forum


$php = $HTTP_POST_VARS['php'];

view.php

Which command or fution shall I use for check box
Can any one help me about this

Thanks in adv


Checkbox's took me a while to get used to using, and get "proficient" at using them. Is what you are doing is trying to make it so you can tell if a checkbox was checked or not? I think that's what you mean. Anyways, if you have to make a checkbox:

Code:
 <input type="checkbox" name="php" value="1">

You can then check if it was checked when the form was submitted by doing:

Code:
if ($_POST['php'] == 1) { 
	$checked = 1; 
			 } else { 
	$checked = 0;
			 }

if ($checked == 0) {

// Do whatever, the checkbox was not checked.

			 } else {

// The checkbox was checked.

			 }

That right there is the method that I use to check if a checkbox is checked. I'm still not sure if that's what you meant, or needed. Also, you should use the "$_POST" global array instead of "$HTTP_POST_VARS". If you need anymore help, if this even was help, PM me, or just post in here...
 
Top