PDA

View Full Version : mail form


berlin28
10-17-2008, 01:50 PM
hi there, i have just enter this web site and i tryied to understand the mail form
Using Dreamweaver and PHP to send form results in an email

i wantet to ask if it is possible not to rediarect to anather page and just stay where it is with empty text field after the Submit.

secondly i wantet to aske if its possible in the code to something so that when the email cames to me the email of the new register user to sign on the From .... so i cann connect it with the auto responder!



thanks a lot.

.ps. is this forum and web site free of charge?

m1a2x3x7
10-17-2008, 02:11 PM
Welcome to the forums. To a lot of us around here Dreamweaver generated PHP code is the devil. I don't use it's code so I'm not 100% sure I can help you but for your first question.

In your form tag set your action to <?php $_SERVER['PHP_SELF'];?>
So it's like this:

<form action="<?php $_SERVER['PHP_SELF'];?>"></form>Once the form is submitted it will just return to this page. Now in order for your script to work your code needs to be included in your page. So at the top of your page you'll need your:

if (isset($_POST['submit']){
mail(bla bla bla);
}I have a feeling that your form action is taking you to your php script.

For your second question what is the auto responder for?

berlin28
10-17-2008, 02:16 PM
at my form i have a Name field and an Email Field
i want to respont to the emails that they are gonna send me from my form
so the Email Field has to be on the from box in my mail!
this is the code i am triing to use

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Results';

// Your email address. This is where the form information will be sent.
$emailadd = 'blbla@blabla.com';

// Where to redirect after form is processed.
$url = 'http://www.fvfdvfv.com';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>


wher schal i white the two codes tha you send me?

m1a2x3x7
10-17-2008, 02:24 PM
ok in your set parameters: take out $url = 'http://www.fvfdvfv.com';

You wont be needing that.

In your do not edit: take out echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';

berlin28
10-17-2008, 02:28 PM
if i take ou this--->In your do not edit: take out echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
then it will not redierect to another page right?


what was then this 2 codes?
PHP Code:
<form action="<?php $_SERVER['PHP_SELF'];?>"></form>



PHP Code:
if (isset($_POST['submit']){
mail(bla bla bla);
}



sorry for the question but i not so gut with php :(

berlin28
10-17-2008, 02:35 PM
yes i actully redairect to my sendresults.php php script :(

m1a2x3x7
10-17-2008, 02:45 PM
That's what I thought it would do.

ok in this case. dont delete anything.

Instead change. $url = 'http://www.fvfdvfv.com';

to the url you want it to go to.

The code i suggested at first wont work correctly since you are requesting the php code from a different page so ignore that.

berlin28
10-17-2008, 02:57 PM
okey that worked and i redairect know to my website index again :)

The only problem know is the email that comes to my email after the registration say From= (my webpage) :( <--here i want the users email that register in my form to sign!
in my form i have tou text fields Name & Email the email has to write From=Email field :)

i dont know if you understand know?

domedia
10-17-2008, 03:08 PM
.ps. is this forum and web site free of charge?Yes, feel free to participate in discussions, help people and post questions all you want 8)

up4dw
10-17-2008, 03:21 PM
[quote=m1a2x3x7;146972]Welcome to the forums. To a lot of us around here Dreamweaver generated PHP code is the devil. I don't use it's code so I'm not 100% sure I can help you but for your first question.


What is the best alternative to PHP in a form results script?

berlin28
10-17-2008, 03:29 PM
okey that worked and i redairect know to my website index again :)

The only problem know is the email that comes to my email after the registration say From= (my webpage) :sad: <--here i want the users email that register in my form to sign!
in my form i have tou text fields Name & Email the email has to write From=Email field :)

i dont know if you understand know?



anyone who knows please ?

m1a2x3x7
10-17-2008, 04:19 PM
[quote=m1a2x3x7;146972]Welcome to the forums. To a lot of us around here Dreamweaver generated PHP code is the devil. I don't use it's code so I'm not 100% sure I can help you but for your first question.


What is the best alternative to PHP in a form results script?

I dont use any other alternative to PHP. I just dont use PHP that Dreamweaver generates. I use PHP that I generate.

m1a2x3x7
10-17-2008, 04:22 PM
berlin your problem is this.

// Your email address. This is where the form information will be sent.
$emailadd = 'blbla@blabla.com';

mail($emailadd, $subject, $text, 'From: '.$emailadd.'');

your var $emailadd is both the to and the from

where it says 'From: '.$emailadd."); you need to replace that with the id of the email textfield so if your textfield has an id of email it would be:

From: '.$_POST['email']");

berlin28
10-17-2008, 04:28 PM
i changed it to From: '.$_POST['email']");
and this came up when i tryied it!
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/stoiacom/public_html/sendresults.php on line 40

m1a2x3x7
10-17-2008, 04:35 PM
can you post the code from your form page?

berlin28
10-17-2008, 04:38 PM
if you mean from my dreamweaver

<form id="Contactform" name="Contactform" method="post" action="sendresults.php">
<label><span class="style10">name</span>
<input type="text" name="name" id="name" />
</label>
<label><span class="style10">Email</span>
<input type="text" name="Email" id="Email" />
</label>
<label>
<input type="submit" name="Submit" id="Submit" value="Submit" />
</label>
<label></label>
<label>
<input type="reset" name="Reset" id="button" value="Reset" />
</label>
</form>

berlin28
10-17-2008, 04:39 PM
if you mean the php :

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$_POST['Email']");
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

m1a2x3x7
10-17-2008, 04:39 PM
give me 5 mins

berlin28
10-17-2008, 04:42 PM
okey thans very much i will wait....

m1a2x3x7
10-17-2008, 04:53 PM
mail($emailadd, $subject, $text, 'From: '.$_POST['Email'].");

sorry needs to have a . at the end of $_POST['Email'].

berlin28
10-17-2008, 05:03 PM
Parse error: syntax error, unexpected T_LNUMBER in /home/stoiacom/public_html/sendresults.php on line 40


still problematik :(

m1a2x3x7
10-17-2008, 05:10 PM
paste all of your sendresults.php code for me. I tested it on my end and it works for me.

berlin28
10-17-2008, 05:15 PM
this is what i use!


<?php
//--------------------------Set these paramaters--------------------------
// Subject of email sent to you.
$subject = 'Newsletter Results';
// Your email address. This is where the form information will be sent.
$emailadd = 'newsletter@4stoixeia.com';
// Where to redirect after form is processed.
$url = 'http://www.4stoixeia.com/index.html';
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';
// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$_POST['Email'].");
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

m1a2x3x7
10-17-2008, 05:21 PM
replace this: echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';

with this:
header("location: $url");
exit;

berlin28
10-17-2008, 05:26 PM
still not! the same error page :(

m1a2x3x7
10-17-2008, 05:30 PM
paste all your sendresults.php code again for me with the header("location: $url");
exit;

in it.

berlin28
10-17-2008, 05:32 PM
<?php
//--------------------------Set these paramaters--------------------------
// Subject of email sent to you.
$subject = 'Newsletter Results';
// Your email address. This is where the form information will be sent.
$emailadd = 'newsletter@4stoixeia.com';
// Where to redirect after form is processed.
$url = 'http://www.4stoixeia.com/index.html';
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';
// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$_POST[Email'].'');
header("location: $url");
exit;
?>

m1a2x3x7
10-17-2008, 05:33 PM
http://www.4stoixeia.com/sendresults.php

is this the link to the php file? if so it redirects me back to your index.html page meaning it working. you might need to clear your cache or do a nice f5 refresh on the form page.

m1a2x3x7
10-17-2008, 05:34 PM
ok you are missing a ' before the word Email


mail($emailadd, $subject, $text, 'From: '.$_POST['Email'].'');

berlin28
10-17-2008, 05:40 PM
hey hey hey
thank you all!! thanks both of you its working!!!!

you are the best!

m1a2x3x7
10-17-2008, 05:43 PM
Anytime Mate.

berlin28
10-23-2008, 09:49 AM
i used this code to send the result to my email:

?php
//--------------------------Set these paramaters--------------------------
// Subject of email sent to you.
$subject = 'Newsletter Results';
// Your email address. This is where the form information will be sent.
$emailadd = 'rgergerg@blabla.com';
// Where to redirect after form is processed.
$url = 'http://www.aagag.com/index.html';
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';
// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$_POST['Email'].'');
header("location: $url");
exit;
?>

how is it possible to adjust it so that when someone apply with a name or an email not to be possible to register again with the same name or email address?

thanks.