Click to See Complete Forum and Search --> : passing input type =text name= email to pop-up form


den
07-14-2004, 06:34 AM
Hi can anyone help me with passing values from one form to a pop-up
form and in doing so how can you add more than one onclick to one button.

Here is the code


<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Eric King (eric_andrew_king@hotmail.com) -->
<!-- Web Site: http://redrival.com/eak/ -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
// End -->
</script>

<DIV style="Z-INDEX: 8; WIDTH: 150px; POSITION: absolute; TOP: 1005px; HEIGHT: 10px; LEFT: 10px"><font face="verdana" font size="1"><b>Add Picture:</b>

<INPUT TYPE="button" VALUE="Click to send Image"
<a href="http://www.psra.com.au/nrdata/picture.htm" onClick="NewWindow(this.href,'name','350','350','yes');return false;" STYLE="height:18px" STYLE="font-size:8pt"></a></font> </div>

Pittimann
07-14-2004, 06:47 AM
Hi!

A couple of things to mention:

Your input tag is not closed,
your anchor tag does not have anything to click on,
instead of using the font tag, you could add the font stuff to the style attributes.

I am having the impression, that you want to allow users to upload an image (your incomplete button has VALUE="Click to send Image"). If that is the case you will have to use an input type=file being part of a form with method="POST" and enctype="multipart/form-data" in the form tag. I also think, that you want to display the image in the popup. That will be impossible using the code you provided.

As far as multiple function calls or stuff to happen onclick of something is concerned, just separate them with ";" - example:

onclick="function1();function2();"

Can you please describe, what you really want?

Cheers - Pit

den
07-14-2004, 07:04 AM
sorry the image/file uploader works

it opens a pop-up with a input field from for them to type
there email address into and then browse there computer to upload a file.

The entire first form is to long to add so I have attached the file

here is the pop-up

<html>
<head>
<title>Send an Email</title>
</head>
<body bgcolor=#e8e8e8>
<DIV
style="Z-INDEX: 8; WIDTH: 200px; POSITION: absolute; TOP: 15px; HEIGHT: 12px; LEFT: 15px"><font face="verdana" color="#000000">
<h3>Register Image</h3></div>
<form action="picture.php" method="POST" enctype="multipart/form-data">
<DIV
style="Z-INDEX: 8; WIDTH: 100px; POSITION: absolute; TOP: 55px; HEIGHT: 12px; LEFT: 15px"><font face="verdana" size="1" color="#000000">
<input type="hidden" name="to" value="dkal3969@bigpond.net.au" STYLE="height:18px" STYLE="font-size:8pt" size=45/><br /></div>

<DIV
style="Z-INDEX: 8; WIDTH: 100px; POSITION: absolute; TOP: 55px; HEIGHT: 12px; LEFT: 15px"><font face="verdana" size="1" color="#000000">
Email Address: <input type="text" name="from" value="" STYLE="height:18px" STYLE="font-size:8pt" size=45/><br /></div>
<DIV
style="Z-INDEX: 8; WIDTH: 100px; POSITION: absolute; TOP: 95px; HEIGHT: 12px; LEFT: 15px"><font face="verdana" size="1" color="#000000">
<p>Attachment: <input type="file" name="fileatt" STYLE="height:18px" STYLE="font-size:8pt" size=45/></p></div>
<DIV
style="Z-INDEX: 8; WIDTH: 315px; POSITION: absolute; TOP: 135px; HEIGHT: 10px; LEFT: 15px">
<hr size="2" width="100%">
</div>

<DIV
style="Z-INDEX: 8; WIDTH: 100px; POSITION: absolute; TOP: 160px; HEIGHT: 12px; LEFT: 15px"><font face="verdana" size="1" color="#000000">
<p><input type="submit" value="Send" STYLE="height:18px" STYLE="font-size:8pt"/></p></div>
</form>
</body>
</html>

the previous form remains active

would prefer that it was one form but haven't the brains to do it yet.

Any help would be greatly appreciated

den
07-14-2004, 07:07 AM
sorry I have never posted so much code before

here are the php files

form.txt php code assigned as mailer.php

<?php

##################################################
#####
# This script is Copyright 2003, Infinity Web Design #
# Distributed by <a href="http://www.webdevfaqs.com" target="_blank">http://www.webdevfaqs.com</a> #
# Written by Ryan Brill - ryan@infinitypages.com #
# All Rights Reserved - Do not remove this notice #
# Also thanks goes to Shimon and Shrine Designs #
##################################################
#####

// email to...
$first = "dkal3969@bigpond.net.au";
$second = "grprofiler@hotmail.com";

$subject = "PSRA web form."; // set the subject line
$from = $_POST['email'];
$forward = 1; // redirect? 1 : yes || 0 : no
$location = "http://www.psra.com.au/nrdata/thanks.htm"; // set page to redirect to, if 1 is above

// date and time
$date = date("l, F jS, Y");
$time = date("h:i A");

// mail the message
$message = "Below is the result of your feedback form. It was submitted on {$date} at {$time}.\n\nIP: {$_SERVER['REMOTE_ADDR']}\n\n";
$method = ($_SERVER['REQUEST_METHOD'] == 'POST') ? $_POST : $_GET;

foreach($method as $key => $value)
{
$key = ucfirst($key);
$message .= "{$key}: {$value}\n";
}
mail($first,$subject,$message,"From:$from");

if($second != NULL)
{
mail($second,$subject,$message,"From:$from");
}
if($forward == 1)
{
header("location :$location");
}
else
{
echo "Thank you for submitting our form. We will get back to you as soon as possible.";
}
?>

also pop-up picture.php

<?php
// Read POST request params into global vars
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['PSRA IMAGE'];
$message = $_POST['HOPE'];
$forward = 1; // redirect? 1 : yes || 0 : no
$location = "http://www.psra.com.au/nrdata/picturethanks.htm"; // set page to redirect to, if 1 is above

// Obtain file upload vars
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];

$headers = "From: $from";

if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);

// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";

// Base64 encode the file data
$data = chunk_split(base64_encode($data));

// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}

// Send the message
if($forward == 1)
{
header("location :$location");
}
$ok = @mail($to, $subject, $message, $headers);
if ($ok) {
echo "<p>Your image has been sent!</p>";
} else {
echo "<p>Mail could not be sent. Sorry!</p>";
}
?>

Pittimann
07-14-2004, 07:27 AM
Hi!

Also the part to open the popup in the file you attached can't work:

<INPUT TYPE="button" VALUE="Click to send Image">
<a href="http://www.psra.com.au/nrdata/picture.htm" onClick="NewWindow(this.href,'name','350','350','yes');return false;" STYLE="height:18px" STYLE="font-size:8pt">nothing here</a>

The button does not have an onclick and the href nothing to click.

Apart from that, you could do the thing in one form (without needing the popup at all), if you put the input type="file" in the main form instead of the useless button '<INPUT TYPE="button" VALUE="Click to send Image">'.

You would just have to use a PHP script, which combines the functionality of Pyro's mailer.php and the picture.php

So you could receive a single email with all the form data and (if the user selects one) the image as an attachment.

Cheers - Pit

den
07-14-2004, 07:36 AM
I know its useless and I would prefer the inpute=file but do you think
I know how to combine the two together. No way I cut and paste

one php into the other and kept on getting line 88 end undefined

when I already had a ?> there

here is one of many combined versions

<?php

##################################################
#####
# This script is Copyright 2003, Infinity Web Design #
# Distributed by <a href="http://www.webdevfaqs.com" target="_blank">http://www.webdevfaqs.com</a> #
# Written by Ryan Brill - ryan@infinitypages.com #
# All Rights Reserved - Do not remove this notice #
# Also thanks goes to Shimon and Shrine Designs #
##################################################
#####

// email to...
$first = "dkal3969@bigpond.net.au";
$second = "grprofiler@hotmail.com";

$subject = "PSRA web form."; // set the subject line
$from = $_POST['email'];
$forward = 1; // redirect? 1 : yes || 0 : no
$location = "http://www.psra.com.au/nrdata/thanks.htm"; // set page to redirect to, if 1 is above

// date and time
$date = date("l, F jS, Y");
$time = date("h:i A");

// mail the message
$message = "Below is the result of your feedback form. It was submitted on {$date} at {$time}.\n\nIP: {$_SERVER['REMOTE_ADDR']}\n\n";
$method = ($_SERVER['REQUEST_METHOD'] == 'POST') ? $_POST : $_GET;

// Obtain file upload vars
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];

if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);

// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";

// Base64 encode the file data
$data = chunk_split(base64_encode($data));

// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
foreach($method as $key => $value)
{
$key = ucfirst($key);
$message .= "{$key}: {$value}\n";
}
mail($first,$subject,$message,"From:$from");

if($second != NULL)
{
mail($second,$subject,$message,"From:$from");
}
if($forward == 1)
{
header("location :$location");
}
else
{
echo "Thank you for submitting our form. We will get back to you as soon as possible.";
}
?>

Pittimann could you please see where I am going wrong?

den
07-14-2004, 08:01 AM
I have changed the input form field where the add picture is located
to

<DIV
style="Z-INDEX: 8; WIDTH: 100px; POSITION: absolute; TOP: 95px; HEIGHT: 12px; LEFT: 15px"><font face="verdana" size="1" color="#000000">Attachment: <input type="file" name="fileatt" STYLE="height:18px" STYLE="font-size:8pt" size=45/></p></div>

I get all the form elements except no attachment.

However I do get at the top of the email I get this

--==Multipart_Boundary_xeca04c72a0faebebde856f120fa00729x
Content-Type: image/gif;
name="logo.gif"
Content-Transfer-Encoding: base64

R0lGODlhOABfAPcAAP//////zP//mf//Zv//M///AP/M///MzP/Mmf/MZv/MM//MAP+Z//+ZzP+Z
mf+ZZv+ZM/+ZAP9m//9mzP9mmf9mZv9mM/9mAP8z//8zzP8zmf8zZv8zM/8zAP8A//8AzP8Amf8A
Zv8AM/8AAMz//8z/zMz/mcz/Zsz/M8z/AMzM/8zMzMzMmczMZszMM8zMAMyZ/8yZzMyZmcyZZsyZ
M8yZAMxm/8xmzMxmmcxmZsxmM8xmAMwz/8wzzMwzmcwzZswzM8wzAMwA/8wAzMwAmcwAZswAM8wA
AJn//5n/zJn/mZn/Zpn/M5n/AJnM/5nMzJnMmZnMZpnMM5nMAJmZ/5mZzJmZmZmZZpmZM5mZAJlm
/5lmzJlmmZlmZplmM5lmAJkz/5kzzJkzmZkzZpkzM5kzAJkA/5kAzJkAmZkAZpkAM5kAAGb//2b/
zGb/mWb/Zmb/M2b/AGbM/2bMzGbMmWbMZmbMM2bMAGaZ/2aZzGaZmWaZZmaZM2aZAGZm/2ZmzGZm
mWZmZmZmM2ZmAGYz/2YzzGYzmWYzZmYzM2YzAGYA/2YAzGYAmWYAZmYAM2YAADP//zP/zDP/mTP/
ZjP/MzP/ADPM/zPMzDPMmTPMZjPMMzPMADOZ/zOZzDOZmTOZZjOZMzOZADNm/zNmzDNmmTNmZjNm
MzNmADMz/zMzzDMzmTMzZjMzMzMzADMA/zMAzDMAmTMAZjMAMzMAAAD//wD/zAD/mQD/ZgD/MwD/
AADM/wDMzADMmQDMZgDMMwDMAACZ/wCZzACZmQCZZgCZMwCZAABm/wBmzABmmQBmZgBmMwBmAAAz
/wAzzAAzmQAzZgAzMwAzAAAA/wAAzAAAm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+ZVt1+iHPNKhP9NkE2kHodv0LpOO
fOSjHn7rWz3goY7KWvaygUDHX7KxgnVc1rI5qmwg1kHa0pa2OM5RBxLbwdrWsracAQEAOw==


--==Multipart_Boundary_xeca04c72a0faebebde856f120fa00729x--


Any help would be greatly appreciated

Pittimann
07-14-2004, 08:17 AM
Hi!

Sorry to you, pyro, for messing up your script.
Sorry to you, den, for not cleaning it up properly, but this should do what you want:<?php

##################################################

#####
# This script is Copyright 2003, Infinity Web Design #
# Distributed by <a href="http://www.webdevfaqs.com" target="_blank">http://www.webdevfaqs.com</a> #
# Written by Ryan Brill - ryan@infinitypages.com #
# All Rights Reserved - Do not remove this notice #
# Also thanks goes to Shimon and Shrine Designs #
##################################################

#####

// email to...
$first = "dkal3969@bigpond.net.au";
$second = "grprofiler@hotmail.com";

$subject = "PSRA web form."; // set the subject line
$from = $_POST['bemail'];
$forward = 0; // redirect? 1 : yes || 0 : no
$location = "http://www.psra.com.au/nrdata/thanks.htm"; // set page to redirect to, if 1 is above

// date and time
$date = date("l, F jS, Y");
$time = date("h:i A");
$message = "Below is the result of your feedback form. It was submitted on {$date} at {$time}.\n\nIP: {$_SERVER['REMOTE_ADDR']}\n\n";
$method = ($_SERVER['REQUEST_METHOD'] == 'POST') ? $_POST : $_GET;

foreach($method as $key => $value)
{
$key = ucfirst($key);
$message .= "{$key}: {$value}\n";
}

$subject = $_POST['PSRA IMAGE'];
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];

$headers = "From: $from";

if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);

// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";

// Base64 encode the file data
$data = chunk_split(base64_encode($data));

// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}

// Send the message
mail($first,$subject,$message,$headers);

if($second != NULL)
{
mail($second,$subject,$message,$headers);
}

//mail($to, $subject, $message, $headers);
if($forward == 1)
{
header("location :$location");
}
else
{
echo "Thank you for submitting our form. We will get back to you as soon as possible.";
}
?>Save this file as the mailer.php (maybe after cleaning it up a bit) and set it as the one and only form's action with the file thingy inside like you already did it.

Cheers - Pit

den
07-14-2004, 09:17 AM
SorryI have taken so long firstly I gave my self whip lash
falling asleep infront of the computer its midnight here.

Secondly I tested it out and it works perfectly thanks a million

Can I ask a silly question. I am receiving it through one email
system a hell of alot faster than the other. Is there a way of regulating the speed of transfer or is that upto the isp server.

Thanks Pittimann

Pittimann
07-14-2004, 09:28 AM
Hi!

You're welcome!

I know it's late now in down under. The different "delivery" times do depend on the server the email goes to.

I am also using scripts, where I receive two emails to different accounts (different domains). One is always a couple of minutes after the other. You cannot do anything concerning that.

Cheers - Pit

PS: don't whip yourself too much - that's not good for the skin. :p

den
07-14-2004, 09:29 AM
Thanks Pittimann

For the help and the chuckle :p

Pittimann
07-14-2004, 09:32 AM
Good night! ;)

Regards - Pit