By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,648 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,648 IT Pros & Developers. It's quick & easy.

Post data to site and get response

P: 2
guys i want some script in which i have some text boxes for user to put in data and then that data goes to a certain site and get the response if the data is valid or not

1.Post data to a site(specific fields)
2.Response (If data is good show Valid data else invalid data)
May 24 '10 #1
Share this Question
Share on Google+
2 Replies


Atli
Expert 5K+
P: 5,058
Hey.

To allow users to enter and send data to your site, you use the <form> element. You can find details on how to use it in this article.

But, basically, you can set up two pages in your site. For example "index.html" and "validate.php". In the HTML page you create a form, and in the PHP page you accept the data and validate it.

index.html
Expand|Select|Wrap|Line Numbers
  1. <form action="validate.php" method="post">
  2.     <input type="text" name="theData"><br>
  3.     <input type="submit">
  4. </form>
validate.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(isset($_POST['theData'])) {
  3.     $theData = $_POST['theData'];
  4.  
  5.     // And now the text you entered
  6.     // into the form is in the $theData
  7.     // variable, so you can use it in any 
  8.     // way you want.
  9. }
  10. else {
  11.     // An error message if the data was
  12.     // not sent with the request. (Meaning
  13.     // that the "validate.php" was requested
  14.     // directly, without using the form.)
  15.     echo "The data was not sent!";
  16. }
  17. ?>
May 24 '10 #2

P: 2
well thanx bro i got that form part that u said only simple noob question can i make my html in FRONTPAGE???
but i did not get the validate.php part :(
well i did not get where i`ll put the url of other site in validate.php on which data is to be validated and then return answer to index.html
May 25 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.