Advertisement

08.23.2004 at 09:20AM PDT, ID: 21103905
[x]
Attachment Details

How to fix my script so it works?

Asked by fdehell in PHP Scripting Language

Tags: fix, script, my

Hi all

My script, or better said the script i created after getting help from the experts here works fine on itself, but i wanted to add email validation to it, which i have tried but it does not work the way i wanted. I had made it so that the user has to check a checkbox before the script wil execute, since the script and the form are on the same page, as someone outhere told me that bwas the best etc etc. But i also do not wish to execute it if no checkboxes were checked, that is, it may execute but i dont like to receive an empty email as you will understand, since that makes not much sense to me, and the script was perfect until i tried to combine it adding email validation. Here is my script, i have a terrible headache so i hope the script will explain what i mean, and what i was trying to do, im aware of making a mess out of this, and cannot even more tell how i started to be honest, so anyone being able to fix the mess i made from it, would be greatly appreciated

Fdehell

<?php
function CheckEmail($sender) {
$sender = $_POST['T1'];
$to = "mail@mail.com";
$subject = "mail";
$mailbody = "";
 if (!ereg("[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+", $sender)) {
  echo "U dient een geldige email op te geven";
  exit;
 }
 else {
 }
}

if (isset($_POST['submit'])){
 $checkarr = $_POST['chkb'];
 foreach ($checkarr as $var) {
  $mailbody .= ". $var.\n";
}
}
if (isset($_POST['agree'])) {
CheckEmail($sender);
mail($to, $subject, $mailbody, "From: $sender") or die ("Fout in script!");
}
?>Start Free Trial
[+][-]08.23.2004 at 09:36AM PDT, ID: 11872275

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Tags: fix, script, my
Sign Up Now!
Solution Provided By: PatrickLucas
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08.23.2004 at 01:18PM PDT, ID: 11874669

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.23.2004 at 02:28PM PDT, ID: 11875335

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]08.24.2004 at 04:04AM PDT, ID: 11879849

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.24.2004 at 09:44PM PDT, ID: 11889254

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32