School Map:  Home / Enroll $ Student Records; Class  
$ News @ LIVE Tech Radio * Support/FAQ | Store | FORUMS

Class / Forums / php101 Refresh the current page Week #6 Basic To-Do Assignment, post here
 

 (#10 2003-08-07 16:13:02) Post Reply

TDavid
php mySQL Perl C/C++
Principal


Enrolled: Mar 2000
Posts: 193
AP: 1

Week #6 Basic TO-DO ASSIGNMENT: Write a script to accept form input and send the comments to and from someone that is input via form, do not hardcode the recipient or the from address.

Add in security to make sure that the "to" and "from" look like legitimate email addresses and use the $PHP_SELF variable. This should all be one self-contained script with NO include() or require() files.

Post this assignment here so that we can offer comment/critique for you, but also post a URL to the working copy of the script and the complete source code of the script in your post here.

scriptname.php <-- script name

Good luck to you!

 

 (#77 2003-08-20 13:16:22) Post Reply

Sk8rRIMuk
Need To Set


Enrolled: Aug 2003
Posts: 39
AP: 1

The URL to my woking script is:
http://www.katikai.com/ee/assi...t/emailform.php

As usual all my past scripts can be found at:
http://www.katikai.com/ee/assignment/

Here is my script:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Week #6 Basic To-Do Assignment</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<table width="750" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top" width="750" height="500">
<?
if($action=="send_mail"){
if(
ereg("([[:alnum:].-]+)(@[[:alnum:].-]+.+)",$receive)){
if(
ereg("([[:alnum:].-]+)(@[[:alnum:].-]+.+)",$email)){
$recipient="$receiven";
$subject="$topic";
$body_of_email="
Thise-mailwassentby$name,
Who'semailis:$email,
Who'swebsiteURLis:$url,
$namealsoleftthiscomment:
$comment"
;
$additional_headers="From:$emailn";
if(
mail($recipient,$subject,$body_of_email,$additional_headers)){
print(
"<p align="center">Yourmailwassuccessfullysentto: <b>$recipient</b></p>");
}else{
print(
"<p align="center">Oops! something didn't work right above, check the syntax of your code.</p>");
}
}else{
print(
"<p align="center">Oops!Itappearsthatyouremail: <b>$email</b>isnotinthecorrectformat</p>");
}
}else{
print(
"<p align="center">Oops!Itappearsthatyouremail: <b>$receive</b>isnotinthecorrectformat</p>");
}
}else{
?>
<form method="post" action="<?$PHP_SELF?>">
<input type="hidden" name="action" value="send_mail" />
Name: <input type="text" name="name" /><br />
Subject: <input type="text" name="topic" size="40" /><br />
Your Email: <input type="text" name="email" size="40" /><br />
Recipient Email: <input type="text" name="receive" size="40" /><br />
URL: <input type="text" name="url" /><br />
Comments: <br /><textarea name="comment" cols="20" rows="10"></textarea><br />
<input type="submit" value="Submit" />
</form>
<?php}?>
</td>
</tr>
</table>
</body>
</html>



I have started using Macromedia Homesite for three reasons:

1) It color codes all script so it easier to understand.

2) It types attributes for you which makes scripting a lot faster :).

3) It tells you of certain errors in your scripts.

 

 (#179 2003-09-10 05:01:56) Post Reply

Quicksaver
Need To Set


Enrolled: Sep 2003
Posts: 90
AP: 1

i have a little problem, i know everything works fine before the mail() function, i couldnt test it completly because my server doesnt support the mail() funtion "for security reasons"... so could someone test it out for me please? thanks :)



<?
if($sent == "true") {
if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $from) && ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $to)) {
$recipient = "$to\n";
$additional_headers = "From: $from\n";
if (
mail($recipient, $subject, $body_of_email, $additional_headers)) {
print(
"Email successfully sent!");
exit(); } else { print(
"<font color=\"ff0000\"><b>Error</b>: please make sure you fill in correctly all the fields in the form.</font>"); } } else {
print(
"<font color=\"ff0000\"><b>Error</b>: please make sure you fill in correctly both email addresses.</font>"); } }
?>

<form method="post" action="<? $PHP_SELF ?>">
<input type="hidden" name="sent" value="true">
From: <input type="text" name="from" size="50"><p>
To: <input type="text" name="to" size="50"><p>
Subject: <input type="text" name="subject" size="50"><p>
Comments: <textarea rows="5" name="body_of_email" cols="30"></textarea><p>
<input type="submit" value="send"><input type="reset" value="reset">
</form>


not entirely working url :P

 

 (#229 2003-09-17 08:04:36) Post Reply

Shrek
Need To Set


Enrolled: Aug 2003
Posts: 33
AP: 1

http://members.lycos.co.uk/jef...wan/class06.htm

I don't know what go wrong with my php. There are many strange character appered in my html.



<html>
<head><title>Start of the HTML </title></head>


<?php
$actionmail
=$_REQUEST['actionform'];
$name=$_REQUEST['name'];
$frommail=$_REQUEST['frommail'];
$tomail=$_REQUEST['tomail'];
$subheader=$_REQUEST['subheader'];
$mailbody=$_REQUEST['mailbody'];

if(
$actionmail == "sendmail")
{
if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $tomail))
{
if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $frommail))
{
if(
mail($tomail,$subheader,$mailbody, $frommail))
{
print(
"mail successfully sent to $recipient.<br>");
}else
{
print(
"Oobs! something didn't work right above, error on $tomail .<br>");
}
}else {
print(
"Mail Address may be incorrect!!! Please Check it!!");
exit;
}
}else {
print(
"Mail Address may be incorrect!!! Please Check it!!");
exit;
}
}
?>

<form method="POST" action="class06.htm">
<input type="hidden" name="actionform" value="sendmail" >

<b>Name:</b><br>
<input type="text" name="name" size="50" value="Jeffrey Kwan"><br>
<b>Your Email:</b><br>
<input type="text" name="frommail" size="50" value="jeffkwan@jeffkwan.no-ip.info"><br>
<b>Recipient Email:</b><br>
<input type="text" name="tomail" size="50" value="jeffkwan@ismart.net.hk"><br>
<b>Subject:</b><br>
<input type="text" name="subheader" size="50" value="Trial Run"><br>
<br><b>Comments:</b><br>
<textarea name="mailbody" cols="39" rows="10"></textarea><br>

<input type="submit" value="Submit">


</form>
</html>



 

 (#234 2003-09-18 01:09:19) Post Reply

Shrek
Need To Set


Enrolled: Aug 2003
Posts: 33
AP: 1

Happy Happy Happy!!! I find out the answer now...
http://members.lycos.co.uk/jef...wan/class06.php

In my last assignment, I use the name as class06.HTM rather than class06.PHP.
When I rename it to class06.PHP, the scripts works. Waste a lot of time but gain a lot experience...



<html>
<head><title>Start of the HTML </title></head>
<?

$actionmail
=$_REQUEST['actionform'];
$name=$_REQUEST['name'];
$frommail=$_REQUEST['frommail'];
$tomail=$_REQUEST['tomail'];
$subheader=$_REQUEST['subheader'];
$mailbody=$_REQUEST['mailbody'];

if(
$actionmail == "sendmail")
{
$frommail="From:".$frommail;
$mailbody="This email is send from Class 06 Basic Assignemnt Program
"
.$mailbody;
if(
ereg('([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)', $tomail))
{
if(
ereg('([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)', $frommail))
{
if(
mail($tomail,$subheader,$mailbody, $frommail))
{
echo(
"<br>mail successfully sent to $recipient.<br>");
} else
{
echo(
"<br>Oobs! something didn't work right above, error on $tomail <br>");
}
} else
{
echo(
"<br>Mail Address may be incorrect!!! Please Check it!!");
}
} else
{
echo(
"<br>Mail Address may be incorrect!!! Please Check it!!");
}
} else
{
}
print(
" <form method='POST' action= ".$_SERVER['PHP_SELF']." >");
print(
" <input type='hidden' name='actionform' value='sendmail' >");
print(
" <b>Name:</b><br> ");
print(
" <input type='text' name='name' size='50' value=''><br>");
print(
" <b>Your Email:</b><br>");
print(
" <input type='text' name='frommail' size='50' value=''><br>");
print(
" <b>Recipient Email:</b><br>");
print(
" <input type='text' name='tomail' size='50' value=''><br>");
print(
" <b>Subject:</b><br>");
print(
" <input type='text' name='subheader' size='50' value=''><br>");
print(
" <br><b>Comments:</b><br>");
print(
" <textarea name='mailbody' cols='39' rows='10'></textarea><br>");
print(
" <input type='submit' value='Submit'>");
print(
"</form>");

?>
</html>


 

 (#256 2003-09-20 07:10:04) Post Reply

Quicksaver
Need To Set


Enrolled: Sep 2003
Posts: 90
AP: 1

ok, i installed php on my local server, but when i tried to do the mail() function this came up:


Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\site\assignement6basic.php on line 7


how do i verify those settings at the php.ini file or how do i use the ini_set() funtion???

 

 (#257 2003-09-20 09:30:26) Post Reply

Shrek
Need To Set


Enrolled: Aug 2003
Posts: 33
AP: 1

Quicksaver,
Have U installed the mail server? For me, I am using Win98/Apache/PHP. In this config, I need to install a mail server from my home. I am now using ArGoSoft Mail Server. http://www.argosoft.com/applic...ver/default.asp

Hope this can help u.

 

 (#261 2003-09-22 05:07:45) Post Reply

Quicksaver
Need To Set


Enrolled: Sep 2003
Posts: 90
AP: 1

thanks shrek, now the mail() thingy works :)

i tested the basic assignement already and it works (to be honest i wasnt expecting it to work at the first try :P) but i have a lil bug on the advanced one. ill work on it but if i cant fix it, well you guys know what to do ;)

 

 (#280 2003-09-26 11:50:53) Post Reply

Donnie
Need To Set


Enrolled: Aug 2003
Posts: 41
AP: 1

Here is the code for week 6 basic assignment. I believe it is right, but if I enter an invalid e-mail address for the sender, it seems that "@myisp.com" is added and it sends it. Link to script:
http://www.dandrenterprises.co...assignment6.php

Here is the code.



<?php
if($action == "send_mail"){
if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $recipient)){
if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $recipient)){
if(
mail("$recipient", "$subject", "$body_of_email", "From: $additional_headers\n")){
print(
"Mail Successfully Sent to: $recipient");
}else{
print(
'OOPS! Something Bad Happened. Mail Not Sent');}
}else{print(
"OOPS! It appears that the e-maill addrss: $additional_headers is not in the correct format.");}
}else{print(
"OOPS! It appears that the e-mail address: $recipient is not in the correct format.");}
}else{
?>
<html>
<head>
<title>Script School PHP Basic Assignment 6</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<h3 align="center"><strong>Script School Basic Assignment 6</strong></h3>
<p align="center"><strong>Mail The Results Of A Form</strong></p>
<center>
<p>Please fill out the following form.</p>
<p>All fields are required. </p>
<form name="form1" method="post" action="<?PHP $PHP_SELF ?>">
<input name="action" type="hidden" value="send_mail">
<table width="80%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="50%"><div align="right">Enter Recipients e-mail Address</div></td>
<td width="40%"><input type="text" name="recipient"></td>
</tr>
<tr>
<td><div align="right">Enter e-mail subject</div></td>
<td><input name="subject" type="text" id="subject"></td>
</tr>
<tr>
<td><div align="right">Enter Comments</div></td>
<td><textarea name="body_of_email" rows="4" id="body_of_email"></textarea></td>
</tr>
<tr>
<td><div align="right">Enter Your e-mail Address</div></td>
<td><input name="additional_headers" type="text" id="additional_headers"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
<p>&nbsp;</p>
</center>
</body>
</html>
<?PHP } ?>



 

 (#289 2003-09-27 02:20:21) Post Reply

maddy
Need To Set


Enrolled: Sep 2003
Posts: 14
AP: 1

All done, I think. I can't post a working URL, becuase my public server seems to have domr issues with sendmail. It works fine on my private server though. :)


<?
if($action=="send_mail"){
if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $toemail)){
if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $fromemail)){
$recipient="$toemail";
$subject="$fromname has recommened an URL";
$body_of_email="
Hi $toname,
Check out this site:$url,
From $fromname
($fromemail)"
;
$additional_headers="From: $fromemail";
if(
mail($recipient,$subject,$body_of_email,$additional_headers)){
print(
"URL successfully sent to $toname ");
}else{
print(
"Oops! something didn't work right above, check the syntax of your code.");
}
}else{
print(
"Plese check that $fromemail is in the correct format for an email address .");
}
}else{
print(
"Plese check that $toemail is in the correct format for an email address.");
}
}else{
?>
<h3>Send An URL to a Friend!</h3>
<form METHOD=POST action="<? $PHP_SELF ?>">
<input type="hidden" name="action" value="send_mail">
Enter the name of your friend: <input type="text" name="toname"><br />
What's their email address? <input type="ext" name="toemail"><br /><br />
Your name: <input type="text" name="fromname"><br />
Your email address: <input type="text" name="fromemail" size=40><br /><br /><b>URL to recommend:</b>
URL: <input type="text" name="url"> <input type="submit" value="Submit"></form>
<? } ?>



 

 (#295 2003-10-01 10:36:45) Post Reply

MarcusD79
Need To Set


Enrolled: Sep 2003
Posts: 10
AP: 1

Well, I am quite confused. I have taken the example scripts you put up and it does not seem to work for me. I have conntacted my service provider and I am able to use mail() function and I am running PHP 4.3.1. Very confused..maybe you have an idea? Here it is, or you can look at it on the Week #6 page, or I have it uploaded to: http://www.fagfrat.com/phpclass/week6tda.php
and http://www.fagfrat.com/phpclass/week6td.php

Here is one:


<?
if(mail("marcusd@fagfrat.com.com", "Test subject line TDavid from php course", "Test body of email", "From: invite@fagfrat.com\n")){
print(
'mail successfully sent to TDavid');
} else {
  print('oops!something didn't work right above, check the syntax of your code');
}
?>

//////////////*
And the other:
*/////////////

<?
if($action=="send_mail"){
    $recipient='
marcusd@fagfrat.com

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /web/sites/tdavid/non_public_system/parsemsg.php on line 94

n
';
    $subject="Just a test from $name";
    $body_of_$email="
     This is the contents of the email from Name: $name
     Who'
s email is: $email
    
and who's URL is: $url
    ";
    $additional_headers="From: $email\n";
    if(mail($recipient, $subject, $body_of_email, $additional_headers)){
       print("mail successfully sent to $recipient");
    } else {
       print('
oops! something didn't work right above, check the syntax of your code');
    } 
} else {
?>
<form METHOD=POST action="<? $PHP_SELF ?>">
<input type="hidden" name="action" value="send_mail">
Name: <input type="text" name="name">
Your Email: <input type="text" name="email" size=40>
URL: <input type="text" name="url"> <input type="submit" value="Submit"></form>
<? } ?>




I do not even get errors, just a blank page.

So, am I a duffus, or is it wrong? I also have a aformmail that currenty uses mail() that someone else built, and when I look in it I see ""mail($_send_to, $_subject, $mail,
"Mime-Version: 1.0\r\nFrom: $_send_from\r\nContent-Type: multipart/mixed;\n boundary=\"$mime_delimiter\"\r\nContent-Disposition: inline");"" and it works. Well, Thanks

MarcusD

 

 (#307 2003-10-10 12:27:15) Post Reply

Quicksaver
Need To Set


Enrolled: Sep 2003
Posts: 90
AP: 1

there's an error on the board's code, could ya fix it TDavy so we can see whats missing on the code? :)

 

 (#313 2003-10-12 10:52:45) Post Reply

jlk242
Need To Set


Enrolled: Oct 2003
Posts: 8
AP: 1

Heres my code, I think it might work, based on the fact that my server tells me I am not allowed to do this, as opposed to getting a parse error...



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>_-=+:: The House of Lycaon ::+=-_</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="141D51" text="#FFFFFF" link="#FFFFFF">
<?php
$set
= 0;
$subject = "Hey Check out these links!";
if (
$action == "send_mail"){
echo (
" $action ");
$set = 1;
$recipient = array($recipient1,$recipient2,$recipient3);
$body_of_email = array('$link1\n','$link2\n','$link3\n');
$additional_headers = "From: $sender\n";
$size = count($recipient);
}
$i = 0;
while (
$i < $size)
{
if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $recipient[$i]))
{
if(
mail("$recipient[$i]","$subject","$body_of_email","$additional_headers"))
{

echo(
"<p> Links successfully sent to $recipient[$i]</p>");

}
else
{
$set = 0;
echo(
"<p>I am sorry, but the links were not sent to $recipient[$i]</p>");
}
}
else
{
$set = 0;
echo(
"<p>I am sorry, but: $recipient[$i] is not in the correct format</p>");
}
$i++;
}
?>
<table width="78%" border="0" align="center">
<form name="mail_form" method="post" action=" <? $PHP_self ?> ">
<input name="action" type="hidden" value="send_mail">

<tr>
<td>
<div align="center"><img src="images/form_head.gif" width="400" height="160"></div></td>
</tr>
<tr>
<td>
<div align="left">
<p align="center">
</p>
<p align="center">To:
<input name="recipient1" type="text" id="recipient1" size="50" maxlength="100">
</p>
<p align="center">To:
<input name="recipient1" type="text" id="\recipient2" size="50" maxlength="100">
</p>
<p align="center">To:
<input name="recipient1" type="text" id="\recipient3" size="50" maxlength="100">
</p>
</div>
</td>
</tr>
<tr>
<td height="21">
<div align="center">From :
<input name="sender" type="text" id="sender" size="50" maxlength="100">
</div>
</td>
</tr>
<tr>
<td height="49">
<div align="center">
<p>Link #1
<input name="link1" type="text" size="50" maxlength="100">
<br>
Link #2
<input name="link2" type="text" size="50" maxlength="100">
<br>
Link #3
<input name="link3" type="text" size="50" maxlength="100">
</p>
</div>
</td>
</tr>
<tr>
<td>
<div align="center">
<input type="submit" name="Submit" value="Submit">
</div>
</td>
</tr>
</form>
</table>
</body>
</html>


 

 (#356 2003-11-03 12:09:24) Post Reply

Dest
Need To Set


Enrolled: Oct 2003
Posts: 18
AP: 1

Ok after few looks to others works i made it. I was trying to make send() with loop but actually, loops sux... so i made that way:

working url: http://tts.lt/~sir/scripts/week6adv.php




<html>
<title>Week 6 advanced to-do assignment </title>
<body>

<?
//Setting up form strings and arrays
$to=array($to0, $to1, $to2);
$url=array($url0, $url1, $url2);
$subject="$friendname sends you 3 URL's";
$body_of_email="Your friend $friendname sends those url's to you:
$url
[0]
$url
[1]
$url
[2]";
$body_url=$url[1];
$additional_headers="From:$from\n";
$sizeof=count($to);
$mailto=$to0.",".$to1.",".$to2;

//If form is done, we will check emails
if($form=="done")
{
//checking emails
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $to[0])&&ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $to[1])
&&
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $to[2])&&ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $from))
{
if(
mail($mailto, $subject, $body_of_email, $additional_headers))
//when urls are sent, print message and exit.
{print("Your URL's were sucessfully sent to: $to[0], $to[1], $to[2]"); }
//if our form dont pass ereg thing we type an error
} else {print("Make sure you typed all mails correctly"); }

}
//welcome message
else{ print("Welcome to our URL-sender script:"); }

?>

<!-main form-->

<form method=POST action=<?$php_self?>>
<input type=hidden name=form value=done>

Write your email and name:<br>
Your mail:&nbsp;&nbsp;&nbsp;<input type=text name=from size=15><br>
Your name:&nbsp;<input type=text name=friendname size=15><br><br>

Write your 3 favourite URL's:<br>
URL 1:&nbsp;<input type=text name=url0 size=40><br>
URL 2:&nbsp;<input type=text name=url1 size=40><br>
URL 3:&nbsp;<input type=text name=url2 size=40><br><br>

Write 3 email adressess you want to send those URL's to:<br>
E-mail 1:&nbsp;<input type=text name=to0 size=15><br>
E-mail 2:&nbsp;<input type=text name=to1 size=15><br>
E-mail 3:&nbsp;<input type=text name=to2 size=15><br><br>

&nbsp;&nbsp;<input type=submit value=Send> &nbsp;<input type=reset value=Clear>
</form>
</body>
</html>



 

 (#371 2003-11-09 09:14:03) Post Reply

doublezero
Need To Set


Enrolled: Nov 2003
Posts: 1
AP: 1

well i tried the advanced to do assigment but than with 10 e-mail adresses. Anyway when i tried the script it looked like working because its sed that the mail was send succesfully but still there are some bugs in it and i never get any mail send :s whats wrong? www.dangerweb.be/allys/tellafriend.php

code
/////////////////////////////////////////////////
<HTML>
<BODY>
<CENTER><H1>TELL A FRIEND ABOUT THIS WEBSITE</h1></center>
<CENTER><FONT SIZE="3">Made by doublezero</font></center>
<BR>
<?
if($action == "send_mail"){
$recipients = array('$mail1', '$mail2', '$mail3', '$mail4', '$mail5', '$mail6', '$mail7', '$mail8', '$mail9', '$mail10');
$sizeof = count($recipients);
$subject = "Your friend , $naam tells your about a good site";
$bodyofmail = "Hi Your friend $naam is telling your by this e-mail about a good site that is located at the following url: www.dangerweb.be/allys His personal comment : $persad";
$additional_headers = "From:$fromwhon";
for($i = 0; $i < $sizeof; $i++) {
if(mail($recipients[$i],$subject,$bodyofmail,$additional_headers)){
print("Tell a friend mail succesfully! send to $recipient[$i]");
}
else {
print("Error , something went wrong , mail not send");
}
}
} else {
?>

<FORM METHOD="post" ACTION="<? $PHP_SELF ?>">
<INPUT TYPE="hidden" name="action" value="send_mail">
<TABLE border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="0"><TR><TD width="600" height="150">
<TABLE border="0" align="center" cellpadding="0" cellspacing="0">
<TR><TD>E-mail adres1:<INPUT TYPE="text" name="mail1" size="15"></td>
<TD>E-mail adres6:<INPUT TYPE="text" name="mail6" size="15"></td></tr>
<TR><TD>E-mail adres2:<INPUT TYPE="text" name="mail2" size="15"></td>
<TD>E-mail adres7:<INPUT TYPE="text" name="mail7" size="15"></td></tr>
<TR><TD>E-mail adres3:<INPUT TYPE="text" name="mail3" size="15"></td>
<TD>E-mail adres8:<INPUT TYPE="text" name="mail8" size="15"></td></tr>
<TR><TD>E-mail adres4:<INPUT TYPE="text" name="mail4" size="15"></td>
<TD>E-mail adres9:<INPUT TYPE="text" name="mail9" size="15"></td></tr>
<TR><TD>E-mail adres5:<INPUT TYPE="text" name="mail5" size="15"></td>
<TD>Emailadres10:<INPUT TYPE="text" name="mail10" size="15"></td></tr>
</table>
</td></tr></table>
<BR>
Your name:<BR><INPUT TYPE="text" name="naam" size="15"><BR>
Your e-mail adres<BR><INPUT TYPE="text" name="fromwho" size="15"><BR>
Personal add:<BR><TEXTAREA name="persad" rows="5" cols="30">

 

 (#391 2003-11-19 15:34:43) Post Reply

zxrod
Need To Set


Enrolled: Oct 2003
Posts: 7
AP: 1

<html>
<body>


<?
if($action=="send_mail") {
$subject="You have a message from $name";
if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $recipient)) {
if(
mail($recipient, $subject, $message, $email)) {
print(
"Your message has been sent to $recipient");
} else {
print(
"Oops! Something didn't work above, please try again");
}
} else {
print(
"It appears that the email: $recipient is not in the correct format");
}
} else {
?>

<form method="Post" Action="<? $PHP_SELF ?>">
<input type="hidden" name="action" value="send_mail">
Name:<input type="text" name="name"><br>
Your Email Address: <input type="text" name="email"><br>
Recipients Email Address: <input type="text" name="recipient"><br>
Message: <textarea rows="2" name="message" cols="26" wrap></textarea><br>
<input type="submit" value="Submit"></form>
<? }?>



</body>
</html>

 

 (#496 2004-02-05 11:31:26) Post Reply

ScriptME
Need To Set


Enrolled: Feb 2004
Posts: 5
AP: 1

Won't Work. WHen I try to send if gives the error message 31 times.



<html>
<head>
<title>E-mail GMs</title>
</head>

<body>


<?

$gm_email
=Array(31);

// ANA E-mail
$gm_email[0]="sfhl_sim@yahoo.ca";

// ATL E-mail
$gm_email[1]="shabymark@yahoo.com";

// Bos E-mail
$gm_email[2]="kentsmith77@hotmail.com";

// BUF E-mail
$gm_email[3]="johnzabroski@yahoo.com";

// CAL E-mail
$gm_email[4]="haliechuk@hotmail.com";

// CAR E-mail
$gm_email[5]="sfhl_sim@yahoo.ca";

// CHI E-mail
$gm_email[6]="PunxRockNYC19@yahoo.com";

// COL E-mail
$gm_email[7]="Avalanche19218@aol.com";

// CBJ E-mail
$gm_email[8]="sfhl_sim@yahoo.ca";

// DAL E-mail
$gm_email[9]="sfhl_sim@yahoo.ca";

// DET E-mail
$gm_email[10]="jan_egert@hotmail.com";

// EDM E-mail
$gm_email[11]="sfhl_sim@yahoo.ca";

// FLA E-mail
$gm_email[12]="j_u_l_15@hotmail.com";

// LA E-mail
$gm_email[13]="washed_up@hotmail.com";

// MIN E-mail
$gm_email[14]="aerohip@telus.net";

// MON E-mail
$gm_email[15]="billy_pecahead@hotmail.com";

// NSH E-mail
$gm_email[16]="oleco@wanadoo.fr";

// NJ E-mail
$gm_email[17]="emil_dzikowski@hotmail.com";

// NYI E-mail
$gm_email[18]="a_suwinski@yahoo.com";

// NYR E-mail
$gm_email[19]="frohli44@optonline.net";

// OTT E-mail
$gm_email[20]="jplbeverage@hotmail.com";

// PHI E-mail
$gm_email[21]="andyclarke88@hotmail.com";

// PHO E-mail
$gm_email[22]="x2002udk@stfx.ca";

// PIT E-mail
$gm_email[23]="Springsteen715@yahoo.com";

// SJ E-mail
$gm_email[24]="cjsastaunik@sasktel.net";

// STL E-mail
$gm_email[25]="heitto@tbaytel.net";

// TB E-mail
$gm_email[26]="hockeyguy4886@hotmail.com";

// TOR E-mail
$gm_email[27]="curtis_tudor@hotmail.com";

// VAN E-mail
$gm_email[28]="sfhl_sim@yahoo.ca";

// WSH E-mail
$gm_email[29]="mo_squared@hotmail.com";

// Commish
$gm_email[30]="sfhl_sim@yahoo.ca";

// Mail Form Info
if($action == "send_mail") {
$recipients = $gm_email;
$subject = $mail_subject;
$body = $message;
$headers = "From SFHL League Site -- ". $team. "\n";
for (
$i=0; $i<31; $i++) {
if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $recipients)) {
if(
mail($recipients[$i], $subject, $body, $headers)) {
print(
"<br>Mail successfully sent to $recipients"); }
}else { print(
"<br>Oops! Something didn't work, error on $recipient[$i]"); }
}
}
else {
?>

<p align="center"><strong><font size="7">E-Mail League</font></strong></p>
<form name="form1" method="post" action="<? $PHP_SELF ?>">
<input type="hidden" name="action" value="send_mail">
<div align="center">
<table width="76%" height="452" border="0">
<tr>
<td width="37%" height="73"><div align="right"><strong>Subject:</strong></div></td>
<td width="55%"><input name="mail_subject" type="text" size="30"></td>
</tr>
<tr>
<td height="116"><div align="right"><strong>Message:</strong></div></td>
<td><textarea name="message" cols="80" rows="10"></textarea></td>
</tr>
<tr>
<td><div align="right"><strong>Your Team:</strong></div></td>
<td> <select size="1" name="team" tabindex="0">
<option></option>
<option>Anaheim</option>
<option>Atlanta</option>
<option>Boston</option>
<option>Buffalo</option>
<option>Calgary</option>
<option>Carolina</option>
<option>Chicago</option>
<option>Colorado</option>
<option>Columbus</option>
<option>Dallas</option>
<option>Detroit</option>
<option>Edmonton</option>
<option>Florida</option>
<option>Los Angeles</option>
<option>Minnesota</option>
<option>Montreal</option>
<option>Nashville</option>
<option>New Jersey</option>
<option>NY Isles</option>
<option>NY Rangers</option>
<option>Ottawa</option>
<option>Philly</option>
<option>Phoenix</option>
<option>Pittsburgh</option>
<option>San Jose</option>
<option>St. Louis</option>
<option>Tampa Bay</option>
<option>Toronto</option>
<option>Vancouver</option>
<option>Washington</option>
<option>Commissioner</option>
</select></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="E-Mail League"></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
</form>
<? } ?>


<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>


 

 (#497 2004-02-05 11:32:55) Post Reply

ScriptME
Need To Set


Enrolled: Feb 2004
Posts: 5
AP: 1

Won't Work. WHen I try to send if gives the error message 31 times.



<html>
<head>
<title>E-mail GMs</title>
</head>

<body>


<?

$gm_email
=Array(31);

// ANA E-mail
$gm_email[0]="sfhl_sim@yahoo.ca";

// ATL E-mail
$gm_email[1]="shabymark@yahoo.com";

// Bos E-mail
$gm_email[2]="kentsmith77@hotmail.com";

// BUF E-mail
$gm_email[3]="johnzabroski@yahoo.com";

// CAL E-mail
$gm_email[4]="haliechuk@hotmail.com";

// CAR E-mail
$gm_email[5]="sfhl_sim@yahoo.ca";

// CHI E-mail
$gm_email[6]="PunxRockNYC19@yahoo.com";

// COL E-mail
$gm_email[7]="Avalanche19218@aol.com";

// CBJ E-mail
$gm_email[8]="sfhl_sim@yahoo.ca";

// DAL E-mail
$gm_email[9]="sfhl_sim@yahoo.ca";

// DET E-mail
$gm_email[10]="jan_egert@hotmail.com";

// EDM E-mail
$gm_email[11]="sfhl_sim@yahoo.ca";

// FLA E-mail
$gm_email[12]="j_u_l_15@hotmail.com";

// LA E-mail
$gm_email[13]="washed_up@hotmail.com";

// MIN E-mail
$gm_email[14]="aerohip@telus.net";

// MON E-mail
$gm_email[15]="billy_pecahead@hotmail.com";

// NSH E-mail
$gm_email[16]="oleco@wanadoo.fr";

// NJ E-mail
$gm_email[17]="emil_dzikowski@hotmail.com";

// NYI E-mail
$gm_email[18]="a_suwinski@yahoo.com";

// NYR E-mail
$gm_email[19]="frohli44@optonline.net";

// OTT E-mail
$gm_email[20]="jplbeverage@hotmail.com";

// PHI E-mail
$gm_email[21]="andyclarke88@hotmail.com";

// PHO E-mail
$gm_email[22]="x2002udk@stfx.ca";

// PIT E-mail
$gm_email[23]="Springsteen715@yahoo.com";

// SJ E-mail
$gm_email[24]="cjsastaunik@sasktel.net";

// STL E-mail
$gm_email[25]="heitto@tbaytel.net";

// TB E-mail
$gm_email[26]="hockeyguy4886@hotmail.com";

// TOR E-mail
$gm_email[27]="curtis_tudor@hotmail.com";

// VAN E-mail
$gm_email[28]="sfhl_sim@yahoo.ca";

// WSH E-mail
$gm_email[29]="mo_squared@hotmail.com";

// Commish
$gm_email[30]="sfhl_sim@yahoo.ca";

// Mail Form Info
if($action == "send_mail") {
$recipients = $gm_email;
$subject = $mail_subject;
$body = $message;
$headers = "From SFHL League Site -- ". $team. "\n";
for (
$i=0; $i<31; $i++) {
if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $recipients)) {
if(
mail($recipients[$i], $subject, $body, $headers)) {
print(
"<br>Mail successfully sent to $recipients"); }
}else { print(
"<br>Oops! Something didn't work, error on $recipient[$i]"); }
}
}
else {
?>

<p align="center"><strong><font size="7">E-Mail League</font></strong></p>
<form name="form1" method="post" action="<? $PHP_SELF ?>">
<input type="hidden" name="action" value="send_mail">
<div align="center">
<table width="76%" height="452" border="0">
<tr>
<td width="37%" height="73"><div align="right"><strong>Subject:</strong></div></td>
<td width="55%"><input name="mail_subject" type="text" size="30"></td>
</tr>
<tr>
<td height="116"><div align="right"><strong>Message:</strong></div></td>
<td><textarea name="message" cols="80" rows="10"></textarea></td>
</tr>
<tr>
<td><div align="right"><strong>Your Team:</strong></div></td>
<td> <select size="1" name="team" tabindex="0">
<option></option>
<option>Anaheim</option>
<option>Atlanta</option>
<option>Boston</option>
<option>Buffalo</option>
<option>Calgary</option>
<option>Carolina</option>
<option>Chicago</option>
<option>Colorado</option>
<option>Columbus</option>
<option>Dallas</option>
<option>Detroit</option>
<option>Edmonton</option>
<option>Florida</option>
<option>Los Angeles</option>
<option>Minnesota</option>
<option>Montreal</option>
<option>Nashville</option>
<option>New Jersey</option>
<option>NY Isles</option>
<option>NY Rangers</option>
<option>Ottawa</option>
<option>Philly</option>
<option>Phoenix</option>
<option>Pittsburgh</option>
<option>San Jose</option>
<option>St. Louis</option>
<option>Tampa Bay</option>
<option>Toronto</option>
<option>Vancouver</option>
<option>Washington</option>
<option>Commissioner</option>
</select></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="E-Mail League"></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
</form>
<? } ?>


<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>


 

 (#620 2004-06-06 09:16:44) Post Reply

Ahkorahil
Need To Set


Enrolled: Oct 2003
Posts: 20
AP: 1

//// I have problem with this code below. It shows form in the webpage, but it won't give any error messages when I insert somthing wrong (e.g. e-mail address)
link to page is <a href="http://members.lycos.co.uk/rain086/php/6.php">here</a>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>6th assignment in pHp</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if(action == "true"){
$subject = "Hello";
$header = "omg";
$body = "hello from $from to $to";
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $to)) {
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $from)) {
if(mail($to, $subject, $body, $header)) {
print("Mail successfully sent!");
} else {
print("Mail was not sent."); }
} else {
print("somthing wrong with address of sender"); }
} else {
print("something was wrong with address of recepient");}
}else{
?>
<form method="post" action="<?php $PHP_SELF ?>">
<input type = "hidden" name = "action" value = "true">
To: <input type="text" name="to" value="" size="20">
<br>
From: <input type = "text" name = "from" value = "" size = "20">
<br>
<input type = "submit" value = "Send plz">
</form>
<?php } ?>
</body>
</html>
l>

 

 (#704 2004-10-04 13:09:58) Post Reply

lestat
Need To Set


Enrolled: Jan 2004
Posts: 44
AP: 1



<?
/* OK this is the example given in week 6
I can't get it to work. I DO have a
formmail that I use regularily that works.
But it's not mine. When you hit 'submit'
This just loops around back to the form -
without any 'yay' or 'nay' message. */
if($_POST['$action'] == "send_mail") {
$recipient = "me@mydomain.com\n";
$subject = "Just a test from $name";
$body_of_email = "This is the contents of the email from Name: $name Whos email is: $email";
$additional_headers = 'From $email';

if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $email)) {
if(
mail($recipient, $subject, $body_of_email, $additional_headers)){
print(
"mail successfully sent to $recipient");
exit();
}else{print(
"oops! something didnt work right above, check the syntax of your code");}
}else{print(
"oops it appears like your email: $recipient is not in the correct format");
}
}else{
?>
<form METHOD=POST action="wk6example.php">
<input type="hidden" name="action" value="send_mail">
Name: <input type="text" name="name">
Your Email: <input type="text" name="email" size=40>
<input type="submit" value="Submit"></form>
<?}?>


 

 (#709 2004-10-05 13:45:10) Post Reply

lestat
Need To Set


Enrolled: Jan 2004
Posts: 44
AP: 1

I cant seem to get the second email address to validate. Any suggestions?

non-working url http://www.timslan.com/scripts...k6/wk6basic.php



<html>
<head>
<title>Week #6 ~ Lestat</title>
<link rel="stylesheet" type="text/css" href="/css/scriptskewl.css">
</head>

<body>

<?

// When button is pushed:
if($_POST['button'] == "push"){

// Assign form entry variables a name
$recipient_name = $_REQUEST['recipient_name'];
$recipient = $_REQUEST['recipient_email'];
$from = $_REQUEST['sender_name'];
$from_email = $_REQUEST['sender_email'];
$breakfast = $_REQUEST['breakfast'];
$lunch = $_REQUEST['lunch'];
$subject = "Some information from $from";
$body_of_email =" Hello $recipient_name, it is $from 's wishes that you recieve this information.
Today I had $breakfast for breakfast.
I will be eating lunch at $lunch.

Thought I would let you know $recipient_name

Have a day,
$from"
;
$additional_headers = "From: $from\n";

// Check email formats
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $recipient)){

// Good format
if(mail($recipient, $subject, $body_of_email, $additional_headers)){
print(
"Thank you $from, your mail has been sent to $recipient");}

// Bad format
}else{print("<font color='red'><strong>Email format is not correct, please try again</strong></font>");}


}
?>

<h4>Fill out this form to have the results sent to someone via email.</h4>

<form method=POST action="<? $PHP_SELF?>">
<input type="hidden" name="button" value="push">
<table border="0">
<tr>
<td><table border="0">
<tr>
<td align="right">To: <input type="text" name="recipient_name" size="10"></td>
<td align="right">Recipients email Address:<input type="text" name="recipient_email" size="20"></td>
</tr>
<tr>
<td align="right">From: <input type="text" name="sender_name" size="10"></td>
<td align="right">Senders email Address:<input type="text" name="sender_email" size="20"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">What you ate for breakfast: <input type="text" name="breakfast" size="15"><br>
What time you will eat lunch: <input type="text" name="lunch" size="15"></td>
</tr>
<tr>
<td align="center"><input type="submit" value="Submit Results"><input type ="reset" value="reset"></td>
</tr>
</table><br><clear="left">

</form>
</body>
</html>


 

 (#712 2004-10-11 10:05:26) Post Reply

lestat
Need To Set


Enrolled: Jan 2004
Posts: 44
AP: 1

Woot! Got it!Just needed a few days awya from code to get a mind reboot :P
Working URL: http://www.timslan.com/scripts...k6/wk6basic.php



<body>

<?

// When button is pushed:
if($_POST['button'] == "push"){

// Assign form entry variables a name
$recipient_name = $_REQUEST['recipient_name'];
$recipient = $_REQUEST['recipient_email'];
$from = $_REQUEST['sender_name'];
$from_email = $_REQUEST['sender_email'];
$breakfast = $_REQUEST['breakfast'];
$lunch = $_REQUEST['lunch'];
$subject = "Some information from $from";
$body_of_email =" Hello $recipient_name, it is $from 's wishes that you recieve this information.
Today I had $breakfast for breakfast.
I will be eating lunch at $lunch.

Thought I would let you know $recipient_name

Have a day,
$from"
;
$additional_headers = "From: $from\n";


// Check Sender Email Syntax
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $from_email)){

// Proceed to check recipient email syntax
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $recipient)){

// If the Sender email is good then - Send the mail
if(mail($recipient, $subject, $body_of_email, $additional_headers)){
print(
"Thank you $from, your mail has been sent to $recipient</body></html>");
exit();
}

}else{
// If Recipient address is bad - bail out
print("<strong>The Syntax, <font color = 'Red'>$recipient</font>, is bad. Mail Not Sent</strong>");
}

}else{
// If Sender address is bad - bail out
print("<strong>The Syntax, <font color = 'Red'>$from_email</font>, is bad. Mail Not Sent</strong>");
}

}
?>

<h4>Fill out this form to have the results sent to someone via email.</h4>

<form method=POST action="<? $PHP_SELF?>">
<input type="hidden" name="button" value="push">
<table border="0">
<tr>
<td><table border="0">
<tr>
<td align="right">To: <input type="text" name="recipient_name" size="10"></td>
<td align="right">Recipients email Address:<input type="text" name="recipient_email" size="20"></td>
</tr>
<tr>
<td align="right">From: <input type="text" name="sender_name" size="10"></td>
<td align="right">Senders email Address:<input type="text" name="sender_email" size="20"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">What you ate for breakfast: <input type="text" name="breakfast" size="15"><br>
What time you will eat lunch: <input type="text" name="lunch" size="15"></td>
</tr>
<tr>
<td align="center"><input type="submit" value="Submit Results"><input type ="reset" value="reset"></td>
</tr>
</table><br><clear="left">

</form>
</body>
</html>


 

 (#781 2005-03-06 10:58:28) Post Reply

zman
Need To Set


Enrolled: Feb 2005
Posts: 15
AP: 1

My Basic Assignment #6:



<html>
<head>
<title>ScriptSchool.com Assignment 6 (basic)</title>

</head>
<body bgcolor="666666">

<?php
// ScriptSchool.com Assignment 6 (basic)
/* Description of assignment: Write a script to accept form input
and send the comments to and from someone that is input via form,
do not hardcode the recipient or the from address. Add in security
to make sure that the "to" and "from" look like legitimate email
addresses and use the $PHP_SELF variable. This should all be one
self-contained script with NO include() or require() files.*/
print("<center><p><b>ScriptSchool.com Assignment 6 - (basic)</b><br />
Description of assignment: Write a script to accept form input<br />
and send the comments to and from someone that is input via form,<br />
do not hardcode the recipient or the from address. Add in security<br />
to make sure that the \"to\" and \"from\" look like legitimate email<br />
addresses and use the \$PHP_SELF variable. This should all be one<br />
self-contained script with NO include() or require() files.</p></center>"
);

if(
$action == "send_mail")
{
$subject = "Some comments from $name";
$body = "
This is the contents of the email from: $name
Who's email is: $email
and who's comments are...
$comments "
;
$additional_headers = "From: $email\n";
if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $email))
{
if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $recipient))
{
if(
mail($recipient, $subject, $body, $additional_headers))
{
print(
"<center>mail successfully sent to $recipient</center>");
}
else
{
print(
"<center>oops! something didn't work right above, check the syntax of your code</center>");
}
}
else
{
print(
"<center>Sorry, but the recipient email address, $recipient, does not appear to be legitimate. - <b>message not sent.<br />Please page back, make any corrections, and try again.</b></center>");
}
}
else
{