memome Posted July 20, 2007 Share Posted July 20, 2007 I am looking for an example script that I can learn off of. I am trying to post variables to a URL via HTML forum. I understand the HTML part, but I am a little fuzzy on the PHP end. the end result of the php script would post a url like this with the variables defined in the HTML forum https://mysite.com/myapplicaion?var1=var1data&var2=var2data&var3=var3data Quote Link to comment Share on other sites More sharing options...
chigley Posted July 20, 2007 Share Posted July 20, 2007 file.html <form action="file.php" method="post"> <input type="text" name="var1" /> <input type="submit" name="submit" value="Submit" /> </form> file.php <?php if(isset($_POST["submit"])) { $var1 = $_POST["var1"]; echo "var1 = {$var1}"; } ?> Very basic, just checks that the form has been submitted and outputs Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 20, 2007 Share Posted July 20, 2007 <?php if (isset($_POST['submit'])){ //get variables from the URL $var1 = $_GET['var1']; $var2 = $_GET['var2']; //....and so on } ?> <form action="site.com?var1=var1data&var2=var2data&var3=var3data" method='post'> <input type='submit' name='submit' value='go'> </form> There is an example for you =] Just let me know if you don't understand something. EDIT: Yeah, I was beat to it. I'm going to post this anyways since I spent the time typing it Quote Link to comment Share on other sites More sharing options...
memome Posted July 20, 2007 Author Share Posted July 20, 2007 Im testing now, thanks for your replies. I will post back results. Thanks! Quote Link to comment Share on other sites More sharing options...
socratesone Posted July 20, 2007 Share Posted July 20, 2007 Of course, if you're just doing this for experimentation reasons, and you want to make ALL the form values URL parameters, the easiest way to do with is to change the form method, ei: <form method="GET"> Quote Link to comment Share on other sites More sharing options...
memome Posted July 20, 2007 Author Share Posted July 20, 2007 Sill a little confused //get variables from the URL $var1 = $_GET['var1']; $var2 = $_GET['var2']; //....and so on This will still work if I am collecting the variables to be used in the URL. Im am trying to just make a little html/php interface to submit txt messages to my SMS provider. They stated that I need to send a message by sending a url like this: https://mysmsprovider.com/Message?UserId=myuseridhere&Password=mypassword&numbertosendto=myphonenumber&MessageText=hi My provider said the I would be able to use PHP to submit a URL like the one above. Most of the examples I was able to find on the net reference pull variables FROM the URL as apposed to submitting to the URL I apologize for my confusion....Im such a n00b Quote Link to comment Share on other sites More sharing options...
Crew-Portal Posted July 20, 2007 Share Posted July 20, 2007 I Posted this somewhere else as well but I think you need the scripta as well so here! <?php //put this at the VERY FIRST LINE in your script! Line 1!!! LINE 1 $page = $_GET['page']; //put this in a table if ($page == NULL){ include 'pages/home.php'; } elseif (file_exists('pages/' . $page . '.php')) { include 'pages/' . $page . '.php'; } elseif ($page == logout){ session_destroy(); } elseif ($page == notloggedin){ echo 'You Are Not logged in! Too Bad'; } else include 'pages/error.php'; ?> Now make a folder called pages in your document root and simplycreate php pages in it (you must include an error and home .php) Now when you link to a document lets say if your document name is test1.php you would make a like as follows: index.php?page=test1 And from there you can assign multiple variables the sasme way but with diffrent names so you could have a page looking like index.php?page=test1&footer=foot2&language=en&advertisement=phpfreaks get it? Then to display the page name on your website... Mainly only for forums! just type <?php echo $page; ?> That was long I am going to get some coffee after that! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.