PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 7th, 1999, 12:59 PM
tigertim
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Can anyone please give me some code to tgake input from a html form and post it into my database.

Thanks
Tim

Reply With Quote
  #2  
Old November 7th, 1999, 01:20 PM
dirk
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
This is basicly done like this:

The form sends it values like this to the action url:

http://url.to.action/script.php3?name=dirk&country=Holland

This would be if the textinputs in your html form where name and country.

In php you can get the so called query string (the part after the ?) into a variable using this syntax:

$query = getenv("QUERY_STRING");

now $query will contain this:
name=dirk&country=Holland

Not really handy yet... But by using the explode function, you can get something usefull out of it:

$values = explode("&", $query);
$name = explode("=", $values[0]);
$name = $name[1];
$country = explode("=", $values[1]);
$country = $country[1];

Now $name has the value dirk and $country holland...

Now you want this in your database.. depends very on what kind of database you use.. I suggest you read the manual found on devshed.com carefully, also on the subject how to get the output from html forms into php3....

Hope this gets you started...

Grtz,

Dirk

Reply With Quote
  #3  
Old November 7th, 1999, 02:05 PM
donarb
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Except, in PHP, you don't need to worry about parsing variables from forms. Just use the variable names in your script, they will contain the values that were posted from the form.

Reply With Quote
  #4  
Old November 7th, 1999, 05:02 PM
scollo
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Donarb is right; you do not need to use getenv("QUERY_STRING") in PHP. It's much simpler than that.

If you have an element like:

<INPUT TYPE="text" NAME="country">

and the user enters "Holland" and submits the form, your receiving script will automatically have a variable called $country with the value "Holland".

You'll need to validate the data to make sure that some cracker isn't trying to slip illegal characters into your database (like, perhaps, backslashes or apostrophes). You can do that with the addslashes() function:

$country = addslashes ($country);

See:
http://www.php.net/manual/function.addslashes.php3

You can then use this validated variable in your SQL statement:

$sql = "UPDATE CustomerInfo SET Country='$country' WHERE RecID=$ID";

or something like that (depending, of course, on what kind of query you're attempting to run).

-- Christopher

Reply With Quote
  #5  
Old November 7th, 1999, 06:20 PM
tigertim
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Thanks for your help, I need specific info as to how to encode it into the form or how to directly input the data from the form. I tried <form enctype="multipart/form-data" method="post" action="<?php echo $PHP_SELF ?>
can you please help me, the error says that the url cannot be found.

thanks
tim

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Html Form Help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap