Jump to content

[SOLVED] Forms Variable help


Markx

Recommended Posts

Hi All

 

I'm stuck with a problem.

I've got 3 pages.

 

1) A form which asks for a name of a user.

2) Uses name and then also posts new information from checkboxes to sendmail.php

3) Is sendmail.php

 

The problem is I need sendmail.php to find what name is from the first page. The 1st page uses GET to send the information to 2nd page.

 

sendmail.php contains a lot of

$c18=$_REQUEST['checkbox'];
$c183=$_REQUEST['checkbox2'];
$c19=$_REQUEST['checkbox3'];

etc 

 

but I can't seem to REQUEST the name from the 1st page

 

I hope you can help

 

Thanks

Markx

Link to comment
https://forums.phpfreaks.com/topic/126169-solved-forms-variable-help/
Share on other sites

you could use sessions to save the info from the first form then recall it at the second from

you could do something like this

//page 2
session_start();
$_SESSION['first_form_data'] = $_REQUEST;

//page 3
session_start();
$username = $_SESSION['first_form_data']['username'];
$name = $_SESSION['first_form_data'][name];

 

Scott.

It would be best to use a session.

 

page 1 asks user name in a form and sends to page 2.

page 2:

<?php
session_start();
$_SESSION['username'] = $_POST['username'];  //make sure the $_POST username gets sanitized first

 

page 3:

<?php
session_start();
$username = $_SESSION['username'];

 

you must use session_start() on each page (at the top is best) in order for this to work.

 

**EDIT**: ratcatme beat me to it :)

Hi Both

 

Thank you for that.

It's working great.

 

Next problem...

 

I'm trying to send the information via email using

 

$message = ",$first,$second,$third,$fourth,$fifth,$sixth,$seventh"

mail("[email protected]","Holiday form", $message );

 

It comes back with

Parse error: syntax error, unexpected T_STRING in /home/ignition/public_html/instructor/sendform.php on line 250

 

I've used echo on all the $first etc and it works fine. The mail command is practically the same as an existing one I use for a completely different form.

 

Any further help would be great  8)

 

Markx

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.