Jump to content

[SOLVED] Feeding data from php form to Web link


martyoo

Recommended Posts

Ok so what I have is a basic form with two fields D and M. when the person enters D and M and clicks Submit I want the contents of D and M to fill their respective areas of a web link.

This the link.

http://website.net/sendsms.aspx?s=m&d=085654321&m=Hi

 

Any ideas?

 

Marty

<?php
if (!isset($_POST[submit])) {
    $form = "yes";
} elseif (isset($_POST[submit])) {
    header("Location: http://website.net/sendsms.aspx?s=m&d=$_POST[d]&m=$_POST[m]");
    exit;
} //end if

if ($form == "yes") {
    $display = "<form action = \"$_SERVER[php_SELF]\" method = \"post\">\n";
    $display .= "<table border = 0>\n";
    $display .= "<tr>\n";
    $display .= "<td align = \"right\">D:</td>\n";
    $display .= "<td><input type = \"text\" name = \"d\"></td>\n";
    $display .= "</tr>\n\n";
    $display .= "<tr>\n";
    $display .= "<td align = \"right\">M:</td>\n";
    $display .= "<td><input type = \"text\" name = \"m\"></td>\n";
    $display .= "</tr>\n\n";
    $display .= "<tr>\n";
    $display .= "<td></td>\n";
    $display .= "<td><input type = \"submit\" name = \"submit\" value = \"Go\"></td>\n";
    $display .= "</tr>\n";
    $display .= "</table>\n";
    $display .= "</form>\n";
} //end if
?>

<html>
<head>
<title>Test Page</title>
</head>
<body>
<p><?php print "$display"; ?></p>
</body>
</html>

 

 

That should do it!

Ok, so with that code it brings up two form fields asking for D and M and when I fill it in it works fine, but what I wanted to do was to get the D and M areas of the web link filled in automatically  and then it would visit the site with the new data.

Is this possible?

Thanks again

 

Marty

Hi,

 

I have a form with two fields D and M. when someone fills out these fields and clicks submit I wanted the data from those two fields to fill the respective areas of the web address and then for the user to be brought to that address.

http://website.net/sendsms.aspx?s=m&d=085654321&m=Hi

 

Thanks

 

 

 

 

 

I must be doing something wrong because when I fill out the form and then submit it through the form that Neptunus made it brings up two empty fields.

If I then enter data on those two fields and click Go it works perfectly. But I wanted it all to happen automatically.

So what I mean is when the data is entered in the form fields the data is then added onto the link and the user is brought to the site.

Am I doing something wrong with the script?

Thanks

 

Marty

You don't need all the code that Neptunus made. All you need is....

 

<form action="http://website.net/sendsms.aspx?s=m" method="get">
  <input type="text" name="d">
  <input type="text" name="m">
  <input type="submit">
</form>

 

as I said in my first reply. Use get as your forms method.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.