PDA

View Full Version : Help Needed: Custom text when opeing a new page


NinjaMoo
06-20-2007, 05:38 PM
Hi,
I dont really know much about PHP and slowly getting to grips with things.
I'm trying to make my own wedding list as this is a nice way to save a bit of money on the whole thing.
I managed to do what I set out, have a list that pops up a contact form which seems to be working and emailing out fine.
But getting into the swing of things I'd kinda want to make it look a little nicer and easier for our guests.

The next step I want to do is this:
I have a list of gifts, when someone clicts on an item I'd like it to open the contact form (as it does now) and
1: Have a thank you message which mentions the gift
2: Automactically include the gift text in the message that is emailed

Is it possible to pass some text when clicking on a link to a new page?

If anyone can point me in the right direction I would be very grateful.

KK

mlseim
06-20-2007, 07:19 PM
This one confuses me a bit ... sorry ...

I'm not sure if you want the thank you message on the same page
as the contact form? or, opens after the contact form is sent?

and if your contact form is already working, why doesn't it already
send the "gift text message" with the email? Isn't that the point
of the contact form?

... finally, are you sure you're talking about passing text on a link,
or passing text using the contact form?

NinjaMoo
06-20-2007, 08:05 PM
Ahhh.
Let me explain a little more in detail then.

The first page has a list of gifts. Next to each gift is a link.
When the link in clicked it opens up a contact form.

The purpose of this form is for guests to send a message to me to let me know what gift they intend to give.
Instead of having the user fill in manually in the form what the gift is I wanted it to be done automtically:
eg
Thank you for getting us 'X', name, message.

So I wanted to know if it was possible to pass the text name of the gift in the link to generate the new page.
Although I'm beggining to think that this might be a job for javascript.

Thanks

KK

mr e
06-20-2007, 09:10 PM
The url won't look pretty, but you could do something like

$gift = 'Silver Platter';
echo '<a href="./contact_form.php?gift='. urlencode($gift) .'">Send Message</a>';

// Then you'd need your contact form page to be php also and you could do

$gift = urldecode($_GET['gift']);
$text = 'Thank you for getting us '. $gift .', we greatly appreciate it!';

// Form stuff etc.

mlseim
06-21-2007, 02:31 PM
Or, have a text file that has this:

1001|Silverware|sdkfjlfk lskdfjlk|sw123.jpg|
1002|Plates|sdjks dfsdfjk|ourplates.jpg|
1003|Glasses|sdfklsdfj sdfjkljkltheglasses.jpg|

Then, your links would be:

<a href="sendgift.php?i=1002">

When the script "sendgift.php" is called, it opens the text file,
looks for item number 1002 and reads the description and any other
text you want (it could be a whole paragraph). PHP opens the file,
reads lines into an array and splits the fields (separated by "pipes" | )

That would keep your URL's short and simple.

Everything is keyed-off of an item number.

In fact, the actual page that displays the links could use the same
flat-file database to create the links, with .jpg images too.

To add more items, you merely append another item onto the text file list.

All pages are created dynamically using that text file.

NinjaMoo
06-22-2007, 01:33 PM
Cool,
thanks guys looks interesting.
Gonna hava a stab at this over the weekend.

Much appreciated.

KK