php to html

I have a data information form that i need sent to an email address and then a redirect to a payment page, i have the data element sorted but cant seem to get it to forward to the payment page, any suggestions, ive been trying now for about a week.

[php]<?php

// Only process POST reqeusts.
if ($_SERVER["REQUEST_METHOD"] == "post") {
    
    
    // Set the recipient email address.
   $recipient = "[email protected]";

    // Set the email subject.
    $subject = "I WANT TO ENTER";

    $eventname = $_POST['eventname'];
    $emailid = $_POST['emailid'];
    $title = $_POST['title'];
    $name = $_POST['name'];
    $address = $_POST['address'];
    $town = $_POST['town'];
    $county = $_POST['county'];
    $postcode = $_POST['postcode'];
    $phone = $_POST['phone'];
    $club = $_POST['club'];
    $swim = $_POST['swim'];
    $tandc = $_POST['tandc'];
   
    // Build the email content.
    $email_content = "EventName: $eventname\n";
    //$email_content = "Email: $email\n\n";
    $email_content = "Event Name: $eventname\n";
    $email_content .= "EmailId: $emailid\n";
    $email_content .= "Title: $title\n";
    $email_content .= "Name: $name\n";
    $email_content .= "Address: $address\n";
    $email_content .= "Town: $town\n";
    $email_content .= "County: $county\n";
    $email_content .= "Postcode: $postcode\n";
    $email_content .= "Phone: $phone\n";
    $email_content .= "Club: $club\n";
    $email_content .= "Swim: $swim\n";
    $email_content .= "Tandc: $tandc\n";

   //assign site mail
    $email = "[email protected]";
    
     // Build the email headers.
    $email_headers = "From:  <$email>";

   // Build the email headers.
    $email_headers = "From:  <$email>";

    // Send the email.
    if(@mail($recipient, $subject, $email_content, $email_headers)) {
        // Set a 200 (okay) response code.
         http_response_code(302); 
header('location: http://www.mywebpage.org.uk/entrypay.html');
    } else {
        // Set a 500 (internal server error) response code.
        http_response_code(302);
header('location: http://www.mywebpage.org.uk/entrypay.html');
    }

     /** 
    * inserting into database
    *connect to database
    * //mysql_connect("localhost", "admin", "password") or die(mysql_error());
    * select database
    * //mysql_select_db("users") or die(mysql_error());
    * //insert email into users table
    * mysql_query("INSERT INTO example (name,email,messagebody) VALUES($name,$email,$message_body) ") or die(mysql_error());
    */ 


} else {
    // Not a POST request, set a 403 (forbidden) response code.
    http_response_code(403);
    header('location: http://www.mywebpage.org.uk/error404.html');
}

?>[/php]

You should not be suppressing errors when you are still in development.

I ran the code and it does redirect. I would say you may have a cache issue. Try a forced refresh.

As i said it does’nt go to the payment page,

It goes directly to the error page and no info is sent.

and whats a forced refresh, lol, sorry

I’m such a newbie, it unreal

So it redirects to your 404 page when you submit the form?

A forced refresh resets the page. In FF it is normally ctrl +F5

So if you look the first two are set to http://www.mywebpage.org.uk

and the last too error404

If i leave it like this it just goes to error 404 and not the payment page,

If i play around with it i can get it to go to the payment page but then i get no information via email, its all to confusing for me.

can we go back to sending letters.

There are two possibilities with what is going on.

  1. Your html form is not set to method=‘post’

  2. You are checking for the request to be post and not POST. It does make a difference.

so changed it from post to POST,

and same thing it went to the page but no info in my in box,

i appreciate your help tho

What box? Your inbox? New form fields?

yes inbox,

But i just noticed its bouncing straight to the last element

[php]} else {
// Not a POST request, set a 403 (forbidden) response code.
http_response_code(403);
header(‘location: http://www.mywebpage.org.uk/entrypay.html’);
}
?>[/php]

and jumping over these elements

[php] if(@mail($recipient, $subject, $email_content, $email_headers)) {
// Set a 200 (okay) response code.
http_response_code(302);
header(‘location: http://www.mywebpage.org.uk/entrypay.html’);
} else {

         // Set a 500 (internal server error) response code.
         http_response_code(302);
 header('location: http://www.mywebpage.org.uk/entrypay.html');
     }[/php]

so i’m surmising there is an issue in the first two elements of the php .

You must have missed what I said in a previous post,

Modify this line of code for starters:

[php]if (strtolower($_SERVER[“REQUEST_METHOD”]) == “post”) {[/php]

And place what I have.

Dude i could bloody kiss you,

whats the charge ?

Thank you so much, you just made my week.

woop woop woop

kudos kudos kudos

There is a donate button… Just sayin… ;D

Cool i can do that :slight_smile:

Had you also posted your form in the first post, you would have gotten a quicker answer to your problem and made it easier for people to help you.

I’m confused… You tell the page to send an error and NOT go the new page, so it is doing what you
asked of it… Doesn’t telling the server to respond to a #403 page send it out to the browser?
If so, then it never executes the HEADER() function… Not sure why you would send out a #403
and then expect the browser to continue on…

Maybe I do not understand the #403 parts?

Sponsor our Newsletter | Privacy Policy | Terms of Service