Jump to content


WANTED: PHP whiz who is willing to help me with an output issue

  • Please log in to reply
4 replies to this topic

#1 fran_456777

  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 October 2006 - 03:00 PM

Hi there,

Right... where do I start? I have a htm page with a PHP script embedded. The PHP script's function is to capture all values entered by a visitor in a form and send it to my email address. I have put the form near the end of the page, so it is not visible when the page loads, unless you scroll down (I hope this makes sense). This script functions fine, but the echo that is returned (upon confirmation that the message is sent, the script "thanks" the visitor) is not placed at the top of the page. So people would have to scroll down to where they filled out the form in order to read the confirmation note. I would like to adapt the code so that the confirmation message is shown at the top of the page in a popup. I have pasted the PHP script in this message. Could someone please have a look at it and suggest what I would have to add in order for this to work??  ???

MANY THANKS!!! Fran xx

$page = new Page("template_skin1.htm");

$name = $_POST["name"];
$url = $_POST["url"];
$email = $_POST["email"];
$msg = $_POST["msg"];
$vword = $_POST["vword"];

echo(" <font face='Arial' size='2' color='#FF0000'><strong>- Enter your name please</strong></font><br />");

function CheckMail($email) {
if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,4}$", $email)) { return true; }
else { return false; }
if ((empty($email)) || (!CheckMail($email)))
echo " <font face='Arial' size='2' color='#FF0000'><strong>- Your email address is invalid</strong></font><br />";

echo(" <font face='Arial' size='2' color='#FF0000'><strong>- Please enter your comment</strong></font><br />");
echo(" <font face='Arial' size='2' color='#FF0000'><strong>- Please enter the verification code that you see in the picture</strong></font><br />");

if(!empty($name) && !empty($email) && !empty($msg) && !empty($vword))
if($vword != "$v_w")
{ echo "<font face='Arial' size='2' color='#FF0000'><strong>- Please enter the verification code that you see in the picture</strong></font>"; }
if($vword == "$v_w")
if(CheckMail($email) == true)
$headers .= "From: ".$email."" .
"Subject: ".$subject."";

$messageproper =
"From: $name - $email \n" .
"------------------------- $yoursitename -------------------------\n\n" .
"Name: $name\n" .
"Rating: $url\n" .
"Email: $email\n\n" .
"Message: $msg\n\n" .
"Sender Ip: $ip" .


mail("$receiver", $subject, $messageproper, "From: $name <$email>");
echo( '<font="arial" color="#003325">Thank you</font><br />

' );
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
"name" => "Name",
"form_name" => "<input type=\"text\" name=\"name\" size=". $field_size ." />",
"email" => "Email",
"form_email" => "<input type=\"text\" name=\"email\" size=". $field_size ." />",
"website" => "Rating",
"form_website" => "<select name=\"url\" rows=". $textarea_row ." cols=". $textarea_cols .">
<option>1 star</option>
<option>2 stars</option>
<option>3 stars</option>
<option>4 stars</option>
<option>5 stars</option>
"message" => "Review",
"form_message" => "<textarea name=\"msg\" rows=". $textarea_row ." cols=". $textarea_cols ."></textarea>",
"vword" => "Verification word",
"form_vword" => "<input type=\"text\" name=\"vword\" size=". $field_size ." />",
"send" => "Send",
"form_send" => "<input type=\"submit\" name=\"send\" value=\"Send Review\" />
<input type=\"reset\" value=\"Reset Form\" /> 

#2 ksteuber

  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts
  • LocationCalifornia, USA

Posted 25 October 2006 - 07:54 PM

I'm having a little truoble making out your code (partially, I think, since i don't know what the includes are), but if I understand the gist of it correctly, you could replace
echo( '<font="arial" color="#003325">Thank you</font><br />');
<?php // notice that i spelled script wrong so that the forum would let me submit my post
echo <<<END
<scipt type="text/javascript">
function disp_alert()
alert("Thank You")

#3 HuggieBear

  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 25 October 2006 - 11:10 PM

OK, someone had to ask...

Why don't you want the user to see the form when they visit the page, why make them scroll down to see it?

Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#4 scar5308

  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 25 October 2006 - 11:16 PM

I am not a php whiz but on my site I just tried changing the line:
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<form method="post" action="different_page.php"target="_blank">

Amazingly, it worked!

You will need to take all the 'Thank you' code and put it on this page along with perhaps a javascript 'Close Window' behavoir

I'm only looking here because I am stuck with a different problem  ;D Good luck

#5 ksteuber

  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts
  • LocationCalifornia, USA

Posted 28 October 2006 - 02:08 AM

I'd have to agree with fran. I would direct the user to a different page. If you want you could even direct them to another page that uses <meta> or javascript to redirect them back to the original page

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users