Refresh before post

software development

#1

Hi, I have a dilema…

I have pageone.php, which contains an inner script, that posts from pageone username, city, state and whenuwanttostart. It posts from within the php page and not an external script. I get an email (results from pageone.php) from this first page when they submit (username, city, state and whenuwanttostart,) all the code is on this page and there is no external cgi post, all of the code is within this first page. Then, technically speaking, it goes to a thank you page. On this page, they can add additional information. I want this page to have(echo) their username, city, state and whenuwanttostart post here (echo the previous pages info). But, due to the fact that the first script/page doesn’t “technically” go to another page (or script,) (you know, I am a lamehead about php and scripts and can’t actually speak the correct terminology, but I will try to explain,) session’s does not work. The only way I could make it work is to somehow refresh the first page, then have the sessions follow. So, I decided to use cookies. But, this was a disaster.

My form results in my email is (sometimes) Jane Doe, janedoe@emailplace.com (even in this forum, I cannot make the % (and) 40 in between janedoe and email place.com show what I am getting.)

I want the results to be Jane Doe, janedow@emailplace.com
This does not always happen. It only happens either

  1. after the user submits the first form. The second form submits the special characters.
  2. if the user already has cookies set with either contact, email, etc. set up by another cookie they got somewhere else.
    I have the cookies set
    {
    SetCookie(“contact”,$contact,time() 36000);
    SetCookie(“EMAIL”,$EMAIL,time() 36000);
    SetCookie(“PHONE1”,$PHONE1,time() 36000);
    SetCookie(“USTART”,$USTART,time() 36000);
    }
    on the second form, I have

    etc. in the form

I am using
and MIME-Version: 1.0\r\nContent-Type: multipart/mixed;boundary=\

So, I thought there could be a way to get rid of those special characters in my emailed form results? If so, I don’t have the answer.

All of the information obtained in these files are set for goldmine import (I know there is a way to change the content header, but don’t know how.) I have to capture the data from the Web and import it into GoldMine with quite a bit of hassles with using these cookies. I want to use sessions, but they don’t work, as pageone.php posts within itself, and doesn’t post to pagetwo.php.

Okay, now I am confused…will post this and maybe change the post or add later. Sadly, I really do want to learn php…but my retention rate is about -10%

barbara


#2

So let’s see.
1)User enters info on pageone.php and submits to pageone.php
2)They confirm information entered on pageone.php
3)The information is passed to pagetwo.php and thank you message appears?

or
3) The information is ‘passed’ to pageone.php and thank you appears?

If it the first step3 then you’ll have to monitor if information is posted. You can do this by
$post_name = @trim($_POST[‘name’]);
$post_name = !empty($post_name) : urldecode($post_name) : “”;

You can then check if the field isn’t empty by (I’ve thrown in the urldecode because that should get rid of the s for you)
if(!empty($post_name)){
//do your own code processing here
//display form second time to confirm input?
}
else{
//Display form here because no information is posted?
}

Again, if doing the first step 3, you’ll need to change where the form points. The first time someone enters information, make the form point to pageone.php with

and then once they've seen the information they've entered, post to pagetwo.php

Then on page two use the above $post_name = … code to get the variables from the form.

If you are using the second set, ie using just one page, then it’s slightly different.
First make the form point to the same page as described above.
But add a field to your form called something like

In your php put
$post_finished = $_POST[‘finished’] == “true” : TRUE : FALSE;

then use similar code to above
if($post_finished){
//echo thank you message and send email
}
elseif(!empty($post_name)){
//do your own code processing here
//display form second time to confirm input?
}
else{
//Display form here because no information is posted?
}

I hope I’ve understood what you asked and not just wasted my time typing all that ^__^;
(If it’s just a registration page, you don’t need to store the information in cookies or sessions, but if you’ll need this again throughout your site, I’ll be able to change the code for you to use these)


#3

I think it is 3) the info is passed to pageone.php, all the script processing code is on pageone.php…

I think I understand what you are saying to do, but am a bit confused about the $post_name = @trim($_POST[‘name’]);

So, I strip out my cookies and use sessions instead?

Here are the actual pages… A person fills out the “Find Out More!” section on this page http://www.protoolstraining.com/catalog/

Once they select submit, (I think you are saying they will then see the info they are submitting and then click, yes submit that information.)

Then they will go to this page http://www.protoolstraining.com/contact/moreinfo.php where the contact, email, phone and when they want to start fields will follow from the previous page?


#4

Well in this case, sessions are better. (Since the information won’t need to be kept when the user leaves the site?)

At the top of every page, before any output/html/blank lines, put session_start();

You can now use
$_SESSION[‘name’] = $_POST[‘name’];
to assign the submitted name to the session and then use $_SESSION[‘name’] to retrieve the information. Note that you won’t be able to access these session variables until you direct your user to a new page.

The @ forces no errors to be displayed, for example if that form variable isn’t set, or trim causes an error. Trim gets rid of any white space and tabs and newlines from the start and end of the string. Useful when someone enters something, otherwise they could put in lots of spaces for the name and your script would still work.