PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 15th, 2002, 09:20 AM
Blake Blake is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 125 Blake User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
passing vars from email to form

I want to make my mailshots a bit more clever for my customers. Basically, I send a mailshot once or twice a month to all names in my database. The customer then RSVP's by clicking the "Yes" or "No" links.
When they click these links, they are presented with a form on my web page.
As all the customers details are in my database, how can I set the process up to automatically fill in as many of the boxes as possible when they click the link? (Such as email address, postal address etc...) I'm fine with querying the DB, I just need to know how to pass the vars to the form from the email.


Reply With Quote
  #2  
Old October 15th, 2002, 10:41 AM
v_jansen v_jansen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Netherlands
Posts: 25 v_jansen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: passing vars from email to form

Are you looking for something like this:

// get vars from database
$name = ...(whatever you use to get data from a database)
etc...

<form>
<input type=text name=name value="<?php print $name ?>">
</form>

Reply With Quote
  #3  
Old October 15th, 2002, 11:29 AM
Blake Blake is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 125 Blake User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: passing vars from email to form

What I am looking for is storing data in a hidden field or as part of the link within the email message received by customers.
My web page displays a form, on the the fields is named email. When the user clicks the link within the email, the field $email is passed thru to my form and inputted into the email field. I could then use the value to query the database and get the rest of the users details.
I have tried using http://mysite.com/yes?email=someone@somewhere.com but it doesn't work.

Reply With Quote
  #4  
Old October 15th, 2002, 01:48 PM
v_jansen v_jansen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Netherlands
Posts: 25 v_jansen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: passing vars from email to form

If you use this in php version 4.1 or later you shoul be able to use

$_GET['email']

to do your db query

else use

$HTTP_GET_VARS['email']

Reply With Quote
  #5  
Old October 15th, 2002, 02:44 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: passing vars from email to form

you could also embed the db unique id for the user (same concept as using the email)in the url sent to the user, then the form page would use that var "id" to query the db, get the info to prefill the form.

Reply With Quote
  #6  
Old October 16th, 2002, 01:13 PM
Blake Blake is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 125 Blake User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: passing vars from email to form

I tried this...
php Code:
Original - php Code
  1.  
  2. function show_form()
  3. {
  4. $id = $_GET['uid'];
  5. mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to connect");
  6. mysql_select_db($dbase) or die("Unable to connect");
  7.  
  8. $query = "SELECT * FROM $dbtable WHERE id = '$id'";
  9. $result = mysql_query($query);
  10. $row = mysql_fetch_row($result);
  11. $email = $row[3]; // 3 being the row in the 4th row in the database (Email)
  12. ?>
  13. <HTML>
  14. <HEAD
  15. <TITLE>Test Form</TITLE>
  16. </HEAD>
  17. <BODY>
  18. <form method="post" action="<?php echo $PHP_SELF ?>">
  19. <input type="text" name="testemail" value="<?php echo $email ?>">
  20. </BODY>
  21. </HTML>
  22. <?php etc...
  23. }

The link within the email simply reads <a href="http://mysite.com?uid=261">Click here</a>
but the field remains blank. What am I doing wrong?

Reply With Quote
  #7  
Old October 16th, 2002, 01:18 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: passing vars from email to form

can you call $_GET within a function? maybe you need to declare it as global first.

Reply With Quote
  #8  
Old October 16th, 2002, 01:36 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: passing vars from email to form

$_GET is a superglobal...no need to declare it global.

Are you sure you are using php version 4.1.0 or higher? If not, use $HTTP_GET_VARS['uid'] and you will need to place global $HTTP_GET_VARS; at the top of your script....

Try echoing out both $HTTP_GET_VARS['uid'] and $_GET['uid'] in your function and seeing if they have values...

Also, $PHP_SELF probably isn't going work inside the function. You will need to place a global $PHP_SELF; at the top of the function to make it work....

Reply With Quote
  #9  
Old October 16th, 2002, 01:57 PM
v_jansen v_jansen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Netherlands
Posts: 25 v_jansen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: passing vars from email to form

are you sure $row contains data

try

print_r($row)

Reply With Quote
  #10  
Old October 16th, 2002, 03:15 PM
Blake Blake is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 125 Blake User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: passing vars from email to form

Thanks guys, worked a treat using
php Code:
Original - php Code
  1. $HTTP_GET_VARS['uid']

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > passing vars from email to form


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway