PHP form with VBscript?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bcanter
    New Member
    • Mar 2007
    • 9

    PHP form with VBscript?

    I have a PHP form that submits information via e-mail, I know that it work fine. My problem is that I want a msgbox to pop up when you submit the form and I can't seem to make it work. I want the form to be sent no matter what the answer is to my msgbox, if they answer yes then it will open a window with another form, if they answer no then the msgbox goes away. Right now I'm not sure how to get the form action to respond to the part that mails it and the msgbox. If I remove the mailing action then it still doesn't work, it just goes to a blank page. Here is my code, I will omit most of the html.

    <head>
    Code:
    <script language="VBScript">
    	  function run()
    	  dim answer
    	  answer=MsgBox("Is the new user replacing the user that they are being modeled after?",4)
    	  document.write(answer)
    	  	if answer=6 then
     			msgbox("Please fill out the following form to have the old user deleted",0)
    			window.open("http://home/php/2.php")
    		else
    	end if
    	end function
     </script>
    </head>
    [php]
    <?php
    ini_set("SMTP", "mymailserver.c om");
    ini_set("sendma il_from","UserR equest@mymailse rver.com");
    if ($_SERVER['REQUEST_METHOD '] != 'POST'){
    $me = $_SERVER['PHP_SELF'];

    ?>
    [/php]
    [html]
    <form method="post" name="form1" id="form1" action="<?=$me? >" action="run()">
    [/html]
    [php]
    <?
    $name = $_POST['name'];
    $position = $_POST["position"];
    $location = $_POST["location"];
    $department = $_POST["department "];
    $user_phone = $_POST["user_phone "];
    $user_email = $_POST["user_email "];
    $manager = $_POST["manager"];
    $manager_phone = $_POST["manager_ph one"];
    $manager_email = $_POST["manager_em ail"];
    $time_zone = $_POST["time_zone"];
    $start_date = $_POST["start_date "];
    $printer = $_POST["printer"];
    $request_type = $_POST["request_ty pe"];
    $access_type_11 = $_POST["access_type_11 "];
    $access_type_12 = $_POST["access_type_12 "];
    $access_type_13 = $_POST["access_type_13 "];
    $access_type_14 = $_POST["access_type_14 "];
    $access_type_15 = $_POST["access_type_15 "];
    $access_type_16 = $_POST["access_type_16 "];
    $model_after_us er1 = $_POST["model_after_us er1"];
    $model_after_11 = $_POST["model_after_11 "];
    $model_after_12 = $_POST["model_after_12 "];
    $model_after_13 = $_POST["model_after_13 "];
    $model_after_14 = $_POST["model_after_14 "];
    $model_after_15 = $_POST["model_after_15 "];
    $model_after_us er2 = $_POST["model_after_us er2"];
    $model_after_21 = $_POST["model_after_21 "];
    $model_after_22 = $_POST["model_after_22 "];
    $model_after_23 = $_POST["model_after_23 "];
    $model_after_24 = $_POST["model_after_24 "];
    $model_after_25 = $_POST["model_after_25 "];
    $notes = $_POST["notes"];
    ?>
    [/php]
    blah blah blah html junk here
    [php]
    <?php
    } else {
    error_reporting (0);
    $errors = array();
    if (!$_POST['name'])
    $errors[] = "Name is required";
    if (count($errors) >0) {
    foreach($errors as $err)
    echo "$err<br>\n ";
    echo "<br>Please use your browser's Back button to fix.";
    } else {
    $recipient = 'me@mymailserve r.com';
    $from = "userreques t";
    $subject = "User Request";
    $msg = "Message sent by $from\n";
    $msg.="\nName: ".$_POST['name'];
    $msg.="\nPositi on: ".$_POST['position'];
    $msg.="\nLocati on: ".$_POST['location'];
    $msg.="\nDepart ment: ".$_POST['department'];
    $msg.="\nUser's Phone: ".$_POST['user_phone'];
    $msg.="\nUser's E-mail: ".$_POST['user_email'];
    $msg.="\nManage r: ".$_POST['manager'];
    $msg.="\nManage r's Phone: ".$_POST['manager_phone'];
    $msg.="\nManage r's Email: ".$_POST['manager_email'];
    $msg.="\nTime Zone: ".$_POST['time_zone'];
    $msg.="\nStart Date: ".$_POST['start_date'];
    $msg.="\nPrinte r: ".$_POST['printer'];
    $msg.="\nReques t Type: ".$_POST['request_type'];
    $msg.="\nPositi on: ".$_POST['position'];
    $msg.="\nAccess Type: ".$_POST['access_type_11 '];
    $msg.="\nAccess Type: ".$_POST['access_type_12 '];
    $msg.="\nAccess Type: ".$_POST['access_type_13 '];
    $msg.="\nAccess Type: ".$_POST['access_type_14 '];
    $msg.="\nAccess Type: ".$_POST['access_type_15 '];
    $msg.="\nAccess Type: ".$_POST['access_type_16 '];
    $msg.="\nModel After User1: ".$_POST['model_after_us er1'];
    $msg.="\nModel After 1: ".$_POST['model_after_11 '];
    $msg.="\nModel After 1: ".$_POST['model_after_12 '];
    $msg.="\nModel After 1: ".$_POST['model_after_13 '];
    $msg.="\nModel After 1: ".$_POST['model_after_14 '];
    $msg.="\nModel After 1: ".$_POST['model_after_15 '];
    $msg.="\nModel After User2: ".$_POST['model_after_us er2'];
    $msg.="\nModel After 2: ".$_POST['model_after_21 '];
    $msg.="\nModel After 2: ".$_POST['model_after_22 '];
    $msg.="\nModel After 2: ".$_POST['model_after_23 '];
    $msg.="\nModel After 2: ".$_POST['model_after_24 '];
    $msg.="\nModel After 2: ".$_POST['model_after_25 '];
    $msg.="\nNotes: ".$_POST['notes'];
    if (mail($recipien t,$subject,$msg )){
    echo "<p>Your request has been sent</p>";
    echo nl2br($msg);
    } else
    echo "An unexpected error has occured";
    }
    }
    ?>
    [/php]
  • bcanter
    New Member
    • Mar 2007
    • 9

    #2
    I figured it out, I used the "onclick" event on the button and that let the form be submitted and still get the pop up.

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Good you figured it out yourself. See you next time.

      Ronald :cool:

      Comment

      Working...