Page 1 of 1
Php "GET" function
Posted: Wed Jun 11, 2003 3:19 pm
by polosport6699
I have been developing a database and I want to have a user fill out a form, then use the "GET" method of posting to send the information to the browser,
Can you have that link automaticly sent to email using a script or mailto:???
This link below is in my browser window. Can i somehow send that value (link) to an email address? Any help is throughly appreaciated
http://localhost/jobcentral/output.php? ... mit=submit
yes
Posted: Wed Jun 11, 2003 3:27 pm
by phpScott
Yes you can using a php script that is using mail()
http://ca2.php.net/manual/en/ref.mail.php
phpScott
I know
Posted: Wed Jun 11, 2003 3:53 pm
by polosport6699
I know that I can send mail using php but I do not know how to get the url address into a variable format to send in the email. Do you understand my dilemma
Posted: Wed Jun 11, 2003 4:12 pm
by cactus
The information submitted by your form will be in the $_POST array, with your <input> names as the keys.
You will need to then concatinate the values in this array and build up your URL, which you could then echo to the browser or mail using the mail() method (as per the reply by phpScott).
Is the intention to allow the recipient of the email to click on the link ??
Or have we lost the plot
Regards,
Posted: Wed Jun 11, 2003 5:30 pm
by patrikG
Actually, if you use GET the values will be in the $_GET-array.
Use a script like this
Code: Select all
<?php
foreach($_GET as $key=>$value)
echo "<br>$key = $value";
?>
and assign the values you need to the
mail-function .
BUT: using $_GET, especially in this instance where you post emails using GET, is a HUGE security-risk. Everyone could use your script to mass-mail whatever they wanted to.
Try using $_POST - which is somewhat safer (but far from 100%).
Posted: Wed Jun 11, 2003 5:35 pm
by cactus
Appologies, I assumed the poster was using POST within the script.
Regards,
Posted: Thu Jun 12, 2003 1:34 am
by patrikG
Well, it is safer to use $_POST so it's just that our two posts should be read from the end of the thread to the beginning to make the order of things alright

Posted: Thu Jun 12, 2003 2:13 am
by cactus
Very true, and you a spot on, POST is way safer than GET, but that's not to say that any reading this shouldn't use GET. Horses for courses.

Hmmm
Posted: Thu Jun 12, 2003 11:15 am
by polosport6699
What would be the code, to go from php form values saying there defined as $value1 $value2 and so on, to emailing thoes values in a clickable link in an auto email
Posted: Thu Jun 12, 2003 12:12 pm
by cactus
You just need to concatinate (glue together) the bits of the $_GET array into a qualified URL:
Code: Select all
$url = "http://".$_GET['DOMAIN']."/".$_GET['FILE']."?x=".$_GET['VAR_X']."&y=".$_GET['VAR_Y']."&z=".$_GET['VAR_Z'];
As dummy data:
Code: Select all
$_GET['DOMAIN'] = "www.devnetwork.net";
$_GET['FILE'] = "index.php";
$_GET['VAR_X'] = "HELLO";
$_GET['VAR_Y'] = "FORUM";
$_GET['VAR_Z'] = "USERS;
Would produce:
http://www.devnetwork.net/index.php?x=H ... UM&z=USERS
As a string in the $url variable, you then need to write this into your message body, as part of the mail() method.
Regards,