Click to See Complete Forum and Search --> : new window to open the mail submitter page


gokou
09-16-2003, 10:37 PM
I have a error validating script on the form called validate(). The script calls a php script to send the mail.

I'm having trouble making the php script open in just a new window and not have it load in the main window also.

I used this code:
onclick="if(!validate()){
window.open(\'submit.php\',\'win_name\',\'the atributes\');}"

That makes the php script load in a new window and the main window. Anyone know how to fix this?

Khalid Ali
09-17-2003, 08:55 AM
Originally posted by gokou

That makes the php script load in a new window and the main window. Anyone know how to fix this?

aaaaaaanh???

Please rephrase your question...:confused: :confused:

pyro
09-17-2003, 08:56 AM
Can we see the rest of the code? Are you submitting a form?

gokou
09-17-2003, 03:43 PM
yeah, i'm submitting a form.

javascript code
function isblank(s){
for(var i = 0; i < s.length; i++) {
var c = s.charAt(i);
if((c != ' ') && (c != '\n') && (c != '')) return false;
}
return true;
}

function validate(f) {
var msg;
var empty_fields = "";

for(var i = 0; i < f.length; i++) {
var e = f.elements[i];
if(((e.type == "text") || (e.type == "textarea")) && !e.optional) {
if((e.value == null) || (e.value == "") || isblank(e.value)) {
empty_fields += "\n " +e.name;
continue;
}
}
}
if(!empty_fields) return true;

msg = "<center>_______________________________</center><br>";
msg+= "<center>The form was not Submitted because of the following error(s).</center>";
msg+= "<center>Please correct these error(s) and re-submit.</center>";
msg+= "<center>_______________________________</center><br>";

if(empty_fields) {
msg+= "<center>The following required field(s) are empty:</center>"
+"<center>"+ empty_fields + "\n";
var emsg = document.createElement("div");
emsg.style.width="auto";
emsg.style.border="outset gray 3px";
document.getElementById("mcontent").appendChild(emsg).innerHTML=msg;
return false;
}
}


php code
<?php
$msg = "First Name: $_POST[first_name]\n";
$msg .="Character Name: $_POST[character_name]\n";
$msg .="Email: $_POST[email]\n";
$msg .="Icq: $_POST[icq]\n";
$msg .="Why do you want to join: $_POST[whyjoin]\n";
$msg .="Characters Skills $_POST[skills]\n";

$recipient ="my email";
$subject ="$_POST[character_name] Application";
$mailheaders = "From: uogameresources.com";
$mailheaders .= "Reply-To:$_POST[email]";

mail($recipient, $subject, $msg, $mailheaders);
?>


When you submit the form, I just want the php page to open in a new window, but not the main window.

pyro
09-17-2003, 05:26 PM
If you are using the transitional or frameset doctype, just use this:

<form action="yourpage.php" method="post" target="_blank">

gokou
09-17-2003, 11:31 PM
K, that will work for now, thanks.

Do you see anything wrong with that php code? It doesn't submit to my email address. It looks pretty much the same as my other one that works except this one has a few more $msg variables.

pyro
09-18-2003, 07:00 AM
Yeah, the PHP should look more like this:

<?php
$msg = "First Name: ".$_POST['first_name']."\n";
$msg .="Character Name: ".$_POST['character_name']."\n";
$msg .="Email: ".$_POST['email']."\n";
$msg .="Icq: ".$_POST['icq']."\n";
$msg .="Why do you want to join: ".$_POST['whyjoin']."\n";
$msg .="Characters Skills ".$_POST['skills']."\n";

$recipient ="you@your.com";
$subject ="$_POST".['character_name']." Application";
$mailheaders = "From: uogameresources.com";
$mailheaders .= "Reply-To:".$_POST['email']."";

mail($recipient, $subject, $msg, $mailheaders);
?>