Problem: My contact.php does not automatically re-direct to my website

I was just wondering if there is anyway I can possibly change the way my contact.php is currently working. At the moment when someone fills up the form on my website they are left with a blank page with a 0 in the top left hand corner, and it really deteriorates the presentation value of the site. What I am looking for is to make the contact.php form do its process but afterwards have it redirect to another page on my website instead of simply sitting on that blank page.

Here is the script I am currently using for my contact.php form:

?php // contact.php
error_reporting(E_ALL);

// ACTIVATE THESE TWO LINES TO SEE THE POST INFORMATION
// echo "<pre>";
// var_dump($_POST);

// THE EMAIL ADDRESS THAT WILL RECEIVE THE MESSAGE
$m = 'info@deconlogic.com';

// A FUNCTION TO CLEAN UP THE INFORMATION AND AVOID BECOMING AN OPEN-RELAY FOR SPAM
function clean_string($str)
{
    $rgx
    = '#'         // REGEX DELIMITER
    . '['         // CHARACTER CLASS
    . '^'         // NEGATION - MATCH NONE OF THESE ACCEPTABLE CHARACTERS
    . ' A-Z0-9_,?/@&*=()!\.\-'
    . ']'         // END OF CHARACTER CLASS
    . '#'         // REGEX DELIMITER
    . 'i'
    ;

    // ELIMINATE EXCESS WHITESPACE
    $str = trim(preg_replace('#\s\s+#', ' ', $str));

    // RETURN THE STRING - BAD CHARACTERS REPLACED WITH THE QUESTION MARK
    return preg_replace($rgx, '?', $str);
}

// CLEAN AND FORMAT THE INFORMATION
$n = clean_string($_POST['n']);
$p = clean_string($_POST['p']);
$e = clean_string($_POST['e']);
$t = clean_string($_POST['t']);

$w = $_SERVER["HTTP_HOST"];

// CREATE THE EMAIL MESSAGE
$b = <<<MESSAGE
Name: $n
Phone: $p
Email: $e
Job Description: $t
MESSAGE;

// SEND THE MESSAGE
mail($m, "Message from $w", $b);

Open in new window


And this is a link to the page which is using this.

Decon - Contact Page

Hopefully someone can help me out, this is thanks in advance.
Ted1984Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

selvolCommented:
PUT this on top of the <body>
<SCRIPT type="text/javascript">
 function goToPage(url)
 {
 var initial = "http://www.page yuou want.com";

 document.something.action=initial;
 }
 </SCRIPT>
Chage you form with this line.
<form method="post" action="contact.php" id="contact-form" onsubmit="goToPage(this.url.value);">

 <INPUT type="text" name="url" value="">
 <INPUT type="submit" value="GO">
 </FORM>
 </BODY>
 </HTML>
0
designatedinitializerCommented:
If you want to redirect to another page, put this line at the end of the script:

header('Location: http://www.deconenviro.com/');

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
You do not need to redirect the client browser.  You can, but it is not necessary.  After line 48 (sends the email message) you can just create a "thank you" page, something like this using heredoc notation.  It can be as simple or elaborate as you would like.  You can load the page via include() or put the HTML string into the contact.php page.
$html = <<<HTML
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<!-- ... REST OF THE HTML PAGE GOES HERE -->
HTML;

echo $html;

Open in new window

0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Ted1984Author Commented:
Should this work?

<?php // contact.php
error_reporting(E_ALL);

// ACTIVATE THESE TWO LINES TO SEE THE POST INFORMATION
// echo "<pre>";
// var_dump($_POST);

// THE EMAIL ADDRESS THAT WILL RECEIVE THE MESSAGE
$m = 'info@deconlogic.com';

// A FUNCTION TO CLEAN UP THE INFORMATION AND AVOID BECOMING AN OPEN-RELAY FOR SPAM
function clean_string($str)
{
    $rgx
    = '#'         // REGEX DELIMITER
    . '['         // CHARACTER CLASS
    . '^'         // NEGATION - MATCH NONE OF THESE ACCEPTABLE CHARACTERS
    . ' A-Z0-9_,?/@&*=()!\.\-'
    . ']'         // END OF CHARACTER CLASS
    . '#'         // REGEX DELIMITER
    . 'i'
    ;

    // ELIMINATE EXCESS WHITESPACE
    $str = trim(preg_replace('#\s\s+#', ' ', $str));

    // RETURN THE STRING - BAD CHARACTERS REPLACED WITH THE QUESTION MARK
    return preg_replace($rgx, '?', $str);
}

// CLEAN AND FORMAT THE INFORMATION
$n = clean_string($_POST['n']);
$p = clean_string($_POST['p']);
$e = clean_string($_POST['e']);
$t = clean_string($_POST['t']);

$w = $_SERVER["HTTP_HOST"];

// CREATE THE EMAIL MESSAGE
$b = <<<MESSAGE
Name: $n
Phone: $p
Email: $e
Job Description: $t
MESSAGE;

// SEND THE MESSAGE
mail($m, "Message from $w", $b);

$html = <<<HTML
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<!-- ... deconenviro.com/formsent2.html -->
HTML;

echo $html;

Open in new window

0
Ray PaseurCommented:
Line 53 is an HTML comment.  I think you might want to read the HTML file deconenviro.com/formsent2.html into a string variable and put that variable in place of the comment.
0
Ted1984Author Commented:
I'm unsure how to turn it into a string variable, is there anyway you can help me with a script? I honestly know nothing about .php or just about any script for that matter, since you can tell I am even scared to remove your descriptions from the code itself.
0
Ray PaseurCommented:
If you don't know PHP but you're trying to write a PHP script, you might as well be trying to write German poetry without knowing German language.  The outcomes are likely to be suboptimal.

You might want to consider hiring a professional to help with this.  If you believe, as I do, that time is money you will undoubtedly find that you can exchange a very little money for a great saving of time.  It's not a scary thing at all; you just need some assistance from someone who is familiar with the languages.  ELance.com is a source for freelance professionals, and I have heard that EE now has a "hire me" section.
0
Ted1984Author Commented:
If I had the money to hire freelancers then I wouldn't be trying to do it myself, or come to a website such as this.

Now if you must know PHP is not poetry, it's not even right to call it a language, at most we can call it a system of grammar, defined by coding which is something so simple you can learn it over night as I just have, but you my friend will not learn poetry in a lifetime.

Now if I had to do PHP in the German Language, it would still not be as complicating as poetry.

Thank you for your help but you've repelled me from continuing a subscription past my trial, and directed me to the web to find my answers.

And in search I found this website and learned all I need to know.

Eureka!
0
Ray PaseurCommented:
Thank you for sharing, Ted1984.  I assumed, apparently incorrectly, that this site was something with economic value and a sponsoring organization that was paying for site development.  And I was quite serious when I said "a very little money."  I'm talking about buying someone a beer, and the thing is all done before the beer is gone.

Tizag is a good site, as is W3Schools.  However they do not have a question and answer dialog like we have here at EE.  The script you posted with the question is one that I wrote.  It's not intended to be a finished product; it is only a teaching example.  You may have figured that out, but as Alexander Pope says, "A little learning is a dangerous thing."  Please don't confuse ignorance with a lack of intelligence.  There are lots of smart people who do not know HTML or PHP (I teach many of them, and it's always a pleasure to see the "lightbulb" go on).  If you knew PHP and HTML you would have implemented the principles shown at ID: 37800827.

In case you ever decide you want to take on some structured learning, this book will help you get a foundation.  Very readable with excellent examples.  Now in its fourth printing, it's been a permanent part of my professional library since Edition One.
http://www.sitepoint.com/books/phpmysql4/

Good luck with your project, ~Ray
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.