Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,673 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,174 people online right now. Registration is fast and FREE... Join Now!




submit forms

2 Pages V  1 2 >  
Reply to this topicStart new topic

submit forms

brainy_creature
post 9 Aug, 2007 - 09:39 AM
Post #1


D.I.C Head

**
Joined: 7 Aug, 2006
Posts: 174



Thanked 1 times
My Contributions


hello... i was trying to make a sumbit form, but osmthing is going wrong somewhere.. please advice

in the main page
<form action="register.php" mode="post>
username:
<input type="text" name="usernme>
password
<input type="password" name="password">
<input type="submit" name="submit">
</form

in register.php

<?php
$con=mysql_connect("fdb1.awardspace.com","username","password") or die("could not connect to the database");
$db=mysql_select("DB name",$con) or die("could not select");
$query="INSERT INTO 'first'('username','password') VALUES('username $_POST[username]','password $_POST[password]')";
$result=mysql_query($query);
mysql_cloase($con):
?>

Like one of my friend told me... this helps to add new entries into the db
but when i refresh my online db (provided by awardspace) there is no new entery.. why??
the commands to add an element is right then wats going wrong?



User is offlineProfile CardPM

Go to the top of the page

no2pencil
post 9 Aug, 2007 - 09:41 AM
Post #2


My fridge be runnin OH NOEZ!

Group Icon
Joined: 10 May, 2007
Posts: 6,354



Thanked 58 times

Dream Kudos: 2375

Expert In: Goofing Off

My Contributions


How are you receiving the values?

If you change from POST to GET, you can see the values in the URL bar.
User is offlineProfile CardPM

Go to the top of the page

mukeshid
post 9 Aug, 2007 - 10:06 AM
Post #3


New D.I.C Head

*
Joined: 1 Aug, 2007
Posts: 17


My Contributions


QUOTE(no2pencil @ 9 Aug, 2007 - 10:41 AM) *

How are you receiving the values?

If you change from POST to GET, you can see the values in the URL bar.


I guess this statement is somewhat wrong, 'password $_POST[password]')
as far as i assume... $_POST[...] should not work within quotes ''

i might be wrong.
you better take values into some variable, and then put it in database. better check by using echo, that weather values are received on server or not.
User is offlineProfile CardPM

Go to the top of the page

brainy_creature
post 9 Aug, 2007 - 10:19 AM
Post #4


D.I.C Head

**
Joined: 7 Aug, 2006
Posts: 174



Thanked 1 times
My Contributions


QUOTE(no2pencil @ 9 Aug, 2007 - 10:41 AM) *

How are you receiving the values?

If you change from POST to GET, you can see the values in the URL bar.

url bar??
how is that going to help.. i mean i want the data to get saved in th db
User is offlineProfile CardPM

Go to the top of the page

brainy_creature
post 9 Aug, 2007 - 10:25 AM
Post #5


D.I.C Head

**
Joined: 7 Aug, 2006
Posts: 174



Thanked 1 times
My Contributions


QUOTE(mukeshid @ 9 Aug, 2007 - 11:06 AM) *

QUOTE(no2pencil @ 9 Aug, 2007 - 10:41 AM) *

How are you receiving the values?

If you change from POST to GET, you can see the values in the URL bar.


I guess this statement is somewhat wrong, 'password $_POST[password]')
as far as i assume... $_POST[...] should not work within quotes ''

i might be wrong.
you better take values into some variable, and then put it in database. better check by using echo, that weather values are received on server or not.

Hello mukesh
i just tried making small adjustments like u said
CODE

<?php
$con=mysql_connect("fdb1.awardspace.com","bakwas_1stone","1stone") or die('couldnot connect');
$db=mysql_select("bakwas_1stone",$con) or die(' could not select');
$var1=$_POST[username];
echo $var1;
$var2=$_POST[password];
echo$var2;
$query="INSERT INTO 'first'('username','password') VALUES($var1,$var2)";
$result=mysql_query($query);
mysql_close($con);
echo "registration sucessfull!('username: $_POST[username]','Password $_POST[password]')";

?>

nothing seems to be working.. not even the echo... i suppose the POST is not working properly.. it not taking any values.. and hence not able to display anything
User is offlineProfile CardPM

Go to the top of the page

mukeshid
post 9 Aug, 2007 - 10:28 AM
Post #6


New D.I.C Head

*
Joined: 1 Aug, 2007
Posts: 17


My Contributions


try $_POST['username'] instead $_POST[username]
User is offlineProfile CardPM

Go to the top of the page

brainy_creature
post 9 Aug, 2007 - 10:31 AM
Post #7


D.I.C Head

**
Joined: 7 Aug, 2006
Posts: 174



Thanked 1 times
My Contributions


QUOTE(no2pencil @ 9 Aug, 2007 - 10:41 AM) *

How are you receiving the values?

If you change from POST to GET, you can see the values in the URL bar.


OMG even get isnt seem to be working
am actually learning and i have a website for practicin thats where am trying.. when am done with learning ill make my dream web
yeah so the link is http://www.bakwas.co.nr
here in "signup" the 1st form... the username and passowrd isnt working

u can check out
even the 2nd form isnt working but there i have tried to implement files
the text will get saved in a file

User is offlineProfile CardPM

Go to the top of the page

mukeshid
post 9 Aug, 2007 - 10:34 AM
Post #8


New D.I.C Head

*
Joined: 1 Aug, 2007
Posts: 17


My Contributions


Use this code, this should work..

HTML PAGECODE..
CODE

<form action="register.php" mode="post">
username: <input type="text" name="username">
password: <input type="password" name="password">
<input type="submit" name="submit" value="submit">
</form>


in register.php

CODE

<?php

$username = 'Username: ' . $_POST['username'];
$password= 'Password: ' . $_POST['password'];


echo $username. '<br>' .$password;


$con=mysql_connect("fdb1.awardspace.com","username","password") or die("could not connect to the database");
$db=mysql_select("DB name",$con) or die("could not select");

$query="INSERT INTO 'first' ('username','password') VALUES('" . $username . "', '" . $password . "')";

$result=mysql_query($query);
mysql_cloase($con):

?>
User is offlineProfile CardPM

Go to the top of the page

no2pencil
post 9 Aug, 2007 - 10:41 AM
Post #9


My fridge be runnin OH NOEZ!

Group Icon
Joined: 10 May, 2007
Posts: 6,354



Thanked 58 times

Dream Kudos: 2375

Expert In: Goofing Off

My Contributions


Just to assure that I have the information I'm thinking I do, I'll generally issue something like this:

CODE

if($_POST['username']) $username = $_POST['username'];
else echo "username was not set!<br>";
if($_POST['password']) $password = $_POST['password'];
else echo "password was not set!<br>";


or you can check for it's existence with isset();
User is offlineProfile CardPM

Go to the top of the page

brainy_creature
post 9 Aug, 2007 - 08:47 PM
Post #10


D.I.C Head

**
Joined: 7 Aug, 2006
Posts: 174



Thanked 1 times
My Contributions


QUOTE(no2pencil @ 9 Aug, 2007 - 11:41 AM) *

Just to assure that I have the information I'm thinking I do, I'll generally issue something like this:

CODE

if($_POST['username']) $username = $_POST['username'];
else echo "username was not set!<br>";
if($_POST['password']) $password = $_POST['password'];
else echo "password was not set!<br>";


or you can check for it's existence with isset();

how does isset() work.. wat is the syntax?

QUOTE(mukeshid @ 9 Aug, 2007 - 11:34 AM) *

Use this code, this should work..

HTML PAGECODE..
CODE

<form action="register.php" mode="post">
username: <input type="text" name="username">
password: <input type="password" name="password">
<input type="submit" name="submit" value="submit">
</form>


in register.php

CODE

<?php

$username = 'Username: ' . $_POST['username'];
$password= 'Password: ' . $_POST['password'];


echo $username. '<br>' .$password;


$con=mysql_connect("fdb1.awardspace.com","username","password") or die("could not connect to the database");
$db=mysql_select("DB name",$con) or die("could not select");

$query="INSERT INTO 'first' ('username','password') VALUES('" . $username . "', '" . $password . "')";

$result=mysql_query($query);
mysql_cloase($con):

?>


hello mukesh
i tried but it doesnt seems to work
User is offlineProfile CardPM

Go to the top of the page

shanu_040
post 9 Aug, 2007 - 09:34 PM
Post #11


New D.I.C Head

*
Joined: 9 Aug, 2007
Posts: 3


My Contributions


<form action="register.php" mode="post">
username: <input type="text" name="username">
password: <input type="password" name="password">
<input type="submit" name="submit" value="submit">
</form>


register.php

<?php

$username = $_POST['username'];
$password = $_POST['password'];


$con=mysql_connect("fdb1.awardspace.com","username","password") or die("could not connect to the database");
$db=mysql_select("DB name",$con) or die("could not select");

$query="INSERT INTO first (username,password) VALUES('$username,'password')";

$result=mysql_query($query);
mysql_cloase($con):

?>

This post has been edited by shanu_040: 9 Aug, 2007 - 09:37 PM
User is offlineProfile CardPM

Go to the top of the page

brainy_creature
post 10 Aug, 2007 - 01:54 AM
Post #12


D.I.C Head

**
Joined: 7 Aug, 2006
Posts: 174



Thanked 1 times
My Contributions




$query="INSERT INTO first (username,password) VALUES('$username,'password')";
i suppose that is one typing error...
my code is the same
the only difference is that after assigning the values to the variables i echo the output (as few ppl here adviced me) but even that is not getting echoed
i doubt something else is going wrong now
if u go to www.bakwas.co.nr which is where am practicin all this..
in the signup page when u click refresh the page isnt getting refreshed instead the home page is opening... so that means i havent really mived from the home page maybe that is creating disturbance to the coding???

Any suggestions as to wat is going wrong?? i suppose the coding for the page is right!!


User is offlineProfile CardPM

Go to the top of the page

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:17AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month