Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> How Do I Pass Php Variables From A Url To A Form?, I'm about read to tear my hair out with this one
Thorned Rose
post Apr 8 2007, 12:58 AM
Post #1


Super Member
*********

Group: Members
Posts: 223
Joined: 16-January 06
From: New Zealand
Member No.: 17,178



Ok, what I need is for users to be able to select what address they want (e.g. mydomain + .com), click submit that then sends the variables 'domain' and 'ext' through the URL e.g. mywebsite.com/example.php?domain=mydomain&ext=com (the variables being mydomain and com) where they are displayed in a form mail as "Domain Selected: mydomain.com" that can then be submitted and sent to an email.

In my form so far I have
CODE
<input name="domainname" type="text" id="domainname" value ="<?php echo "$domain"; ?>">

but it don't do poo and I'm sure that anyone in the know is laughing at my sad attempt at PHP but if you could please tell me how I call both variables from the URL so that they display in the form as one whole address (i.e. mydomain.com not my domain and com) that would be very much appreciated!
Go to the top of the page
 
+Quote Post
jlhaslip
post Apr 8 2007, 01:56 AM
Post #2


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



*edit*
What you have there uses the $domain variable. In order to grab the values from the URL, use the $_GET array.

CODE
<input name="domainname" type="text" id="domainname" value ="<?php echo $_GET['domain']; ?>">
<input name="extensionname" type="text" id="extensionname" value ="<?php echo $_GET['ext']; ?>">


Withput seeing the entire code you are using, this is my best guess. If this doesn't work for you, please re-post with the entire code. Well, at least the Form in question and the receiving script. Thanks.
Go to the top of the page
 
+Quote Post
Thorned Rose
post Apr 8 2007, 02:14 AM
Post #3


Super Member
*********

Group: Members
Posts: 223
Joined: 16-January 06
From: New Zealand
Member No.: 17,178



I can't give you the form for the part that generates the URL as that is a component for Joomla!, just that it outputs the variables in a url that looks like mywebsite.com/example.php?domain=mydomain&ext=com
Here's a simple form (sorry it's messy) with how I want to output the variables domain and ext

CODE
<form action="process.php" method="post">
<input type=hidden name="subject" value="Domain Request">
  <div align="center">Name:
    <input type="text" name="name" size="30" maxlength="30" />
      <br />
      <br />
    Email:
  <input type="text" name="email" size="30" maxlength="30" />
  <br />
  <br />
    Domain:
  <input name="domainname" type="text" id="domainname" value ="<?php echo "$domain" "$ext"; ?>">
  <br />
  <br />
  <input type="submit" name="submit" value="Send" />
  </div>
</form>

This form should display the variables in a text box as "mydomain.com". People can then finish putting in their name and email and hit send which should then send all the form info to an email address.

My process.php so far looks like this:

CODE
<?php
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($subject);
$domainname = stripslashes($domainname);
mail('email@address.com',$subject,$domainname,"From: $name <$email>");
header("location:form.php");
?>


It's displaying the variables from the url within the form that have me stumped so far.
Go to the top of the page
 
+Quote Post
jlhaslip
post Apr 8 2007, 02:22 AM
Post #4


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



This is going to get a bit confusing because Joomla is using the $_GET Superarray and you are using the $_POST Superarray, so adjust the $_GET's and $_POST's accordingly. Your form shows the method=POST, so you will need to use the $_POST array to display your data, but Joomla is using the $_GET array(method) and that will require using the $_GET values for where you receive their data.

When the variables are physically included in the URL, use the $_GET array.

*edit*

CODE
<?php echo $domain . '.' . $ext; ?>
to add the 'dot' in the output.
Go to the top of the page
 
+Quote Post
Thorned Rose
post Apr 8 2007, 09:11 PM
Post #5


Super Member
*********

Group: Members
Posts: 223
Joined: 16-January 06
From: New Zealand
Member No.: 17,178



Wohoo! I got it. I combined the two things you said jlhaslip to get:

CODE
<input name="domainname" type="text" id="domainname" value ="<?php echo $_GET['domain']. '.' . $_GET['ext']; ?>">

And it works perfectly.

Thanks for all your help dude! You are a legend as always! smile.gif
Go to the top of the page
 
+Quote Post
jlhaslip
post Apr 8 2007, 09:26 PM
Post #6


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



And I'm not even a Hobbit... glad it worked. smile.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Transfer Variables To Another Php Script(8)
  2. Session Variables(4)
  3. Storing Session Variables Generated Dynamically(3)
  4. Sending $_get[] Variables To An Application(3)
  5. Php Sessions And Post Variables Issues(1)
  6. Counting Variables?(4)


 



- Lo-Fi Version Time is now: 25th July 2008 - 09:02 PM