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

<?php
require_once("config2.php");
require_once("templ_core1.php");
$page = new Page("template_skin1.htm");

if(isset($_POST["send"]))
{
$name = $_POST["name"];
$url = $_POST["url"];
$email = $_POST["email"];
$msg = $_POST["msg"];
$vword = $_POST["vword"];
$ip = $_SERVER['REMOTE_ADDR'];


if(empty($name))
{
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 />";
}

if(empty($msg)){
echo(" <font face='Arial' size='2' color='#FF0000'><strong>- Please enter your comment</strong></font><br />");
}
if(empty($vword)){
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" .

"\n------------------------------------------------------------\n";

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

' );
                }
} 
}
}
else
{
?>
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<?php
$page->replace_tags(array(
  "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>
              </select>",
  "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\" /> 
  </form>"
));
$page->output();
?>
<?php 
}
?>

    Fran,

    Please excuse my ignorance, but how can it be at the top of the page and in a popup? It would seem to be an either/or type of thing.

    If you're looking to place the data in a popup, then it seems like this is strictly a client-side language issue, as you would use js or dhtml to take care of what you want to do.

    thanks,
    json

      Thank you json,

      My main problem is that when my visitor submits his/her comments, the page is reloaded and the echo is returned at the bottom of the page where the PHP code is placed (I have used <?php include "comment.php"; ?> ). So all I would need really is for the page to reload as normal but for the echo to be displayed at the top of the page, making it more user-friendly. I am sorry if I didn't express myself very well :-) I have tried 3 forums so far but everyone seems to think it is an impossible thing to do... ?? Do you have a solution?

      Thx, Fran

        Hi there Fran,

        I don't see a reference to comment.php in the code posted above, so I may be misunderstanding the problem, but if I'm not:

        Why can't you set a value to a variable on form submission, and at the top of the page that you want the comment to show up on:

        Submission page:

        $thanks=1;
        

        Page you want the thanks comment to appear:

        if(isset($_GET['thanks'])){
        
         echo("Thanks so much!");
        
        }
        

        Like I said, I might be misunderstanding your problem, so let me know if I've oversimplified it.

        thanks,
        json

          Thanks so much json, I got the thing working properly !! Just one last thing: on the line where I say "thank you" :

          echo( '<font="arial" color="#003325">Thank you</font><br />
          

          For some strange reason, I can't get the colour to show up properly. No matter what colour code I put in, it always comes up as plain old black... (I have tried to replace "#003325" with /"#003325/" but to no avail...

          I know I'm bothering you with this, but do you happen to have the magic code? Thx :-) Fran

            Hi there again fran,

            It's probably being overridden by a stylesheet that is being loaded by the page. You can't get text controlled by .css files to change color with font tags.

            You can edit your stylesheet to include a new class and control the color weight and font that way.

            thanks,
            json

              Brilliant! I will try that json. Thank you so much for all your help; you're a star x

                Glad it's working for you. It's a rare occurance when my posts are offering assistance instead of asking for it. You've been part of a special occasion 🙂

                thanks,
                json

                  You can always override css styles by defining style to it. But dont use <font> because its deprecated. Use span instead:

                  echo '<span style="font: arial; color: #003325">Thank you</span><br />';
                  
                    Write a Reply...