Page 1 of 1

How to open a new popup windows?

Posted: Tue Feb 09, 2010 10:03 am
by ipohismytown

Code: Select all

function spamcheck($field)
  {
  //filter_var() sanitizes the e-mail
  //address using FILTER_SANITIZE_EMAIL
  $field=filter_var($field, FILTER_SANITIZE_EMAIL);
 
  //filter_var() validates the e-mail
  //address using FILTER_VALIDATE_EMAIL
  if(filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }
?>

Code: Select all

<?php
 
if (isset($_REQUEST['email']) && $_REQUEST['email'] != "")
//if "email" is filled out, send email
{
    $mailcheck = spamcheck($_REQUEST['email']);
    if(!checkEmail($_POST['email']) && $mailcheck==FALSE)
    {
        //check if the email address is invalid
        echo("<script language='JavaScript'>
        window.alert('Unvalid email! Please correct it.')
        </script>"); 
        echo "<form method='post' action=''>    
        <table border='0' cellpadding='0' cellspacing='5' style='padding-left:10px' class='contactform'>
        <tr>
        <th colspan='2' style='font-size:13px; padding:5px; padding-left:0px; text-decoration:underline'>Contact Us Form</th>
        </tr>
        <tr>
        <td>Email</td>
        <td> : </td>
        <td><input name='email' type='text' class='text' size='30'></td>
        </tr>
        <tr>
        <td>Subject</td>
        <td> : </td>
        <td><select name='subject' style='width:154px'>
            <option value='General'>General</option>
            <option value='Enquiry'>Enquiry</option>
            </select>
        </td>
        </tr>
        <tr>
        <td>Message</td>
        <td> : </td>
        <td><textarea name='message' rows='6' cols='50'></textarea></td>
        </tr>
        <tr>
        <td colspan='2'><input name='sendemail' type='hidden' class='text' value='1' /></td>
        <td style='padding-top:5px'><input type='submit' name='btnSubmit' value='Submit' style='vertical-align:bottom' /></td>
        </tr>
        </table>
        </form>";
                    
    }else{
  //send email
          $email = $_POST['email'] ;
          $subject = $_POST['subject'];
          $message = $_POST['message'] ;
          
          
          mysql_query("INSERT INTO feedback(fb_from,fb_subject,fb_content) VALUES ('". $email ."','".$subject."','".$message."')");
          
            if(mysql_affected_rows() == 1){
                echo("<script language='JavaScript'>
                window.alert('General/Enquiry have been sent! Thank you.')
                </script>");
            }else{
                echo("<script language='JavaScript'>
                window.alert('Failed!')
                </script>"); 
            }
 
    }
}else
    //if "email" is not filled out, display the form
{
  
    echo "<form method='post' action=''>    
        <table border='0' cellpadding='0' cellspacing='5' style='padding-left:10px' class='contactform'>
        <tr>
        <th colspan='2' style='font-size:13px; padding:5px; padding-left:0px; text-decoration:underline'>Contact Us Form</th>
        </tr>
        <tr>
        <td>Email</td>
        <td> : </td>
        <td><input name='email' type='text' class='text' size='30'></td>
        </tr>
        <tr>
        <td>Subject</td>
        <td> : </td>
        <td><select name='subject' style='width:154px'>
            <option value='General'>General</option>
            <option value='Enquiry'>Enquiry</option>
            </select>
        </td>
        </tr>
        <tr>
        <td>Message</td>
        <td> : </td>
        <td><textarea name='message' rows='6' cols='50'></textarea></td>
        </tr>
        <tr>
        <td colspan='2'><input name='sendemail' type='hidden' class='text' value='1' /></td>
        <td style='padding-top:5px'><input type='submit' name='btnSubmit' value='Submit' style='vertical-align:bottom' /></td>
        </tr>
        </table>
</form>";
}
?>

I want to write a page for give customer send feedback form. After submit the form will send mail but i using localhost so i change to another way. Once i fill up the form and submit. It will popup a new windows display subject,message,email(once submit it will insert a query and will delete after display) and the page for feedback form still remain as the fill in form. How to do that can anyone help?

Re: How to open a new popup windows?

Posted: Tue Feb 09, 2010 11:03 am
by a.heresey
I think your question is about making the form sticky, not popup windows?

Code: Select all

 
        echo "<input name=\"email\" value=\"";
        if(isset($_POST['email'])){
                 echo $_POST['email'];
       }
       echo "\" />";
 
 
http://www.webproworld.com/web-programm ... g-php.html

you should sanitize your data before inserting it into your database, just saying.

Re: How to open a new popup windows?

Posted: Tue Feb 09, 2010 12:01 pm
by ipohismytown
Erm....actually i just want popup a new windows display the subject, message and e-mail for proving the message already send out because i using localhost so cannot configure with the sendmail() function. Someone ask me use <form action="sendsuccess.php" target="_blank"> for run on sendsuccess.php but i want run on the page and popup after send out