DoobyWho
08-14-2002, 01:58 AM
TO-DO ASSIGNMENT: Write a "Share these urls with your friends" script which will send a series of at least 3 different urls that the user must enter into the form to at least 3 different email addresses. 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.
RRolfe
08-14-2002, 08:56 AM
ok now... really.
i have been away from WHT for a while but are these really "challenges" or are they just scripts that you need written because you don't know how?
Tux-e-do
08-14-2002, 08:59 AM
:D free labour, creative ways :D
RRolfe
08-14-2002, 09:01 AM
well like i said i just came back from my "WHT break" and i found this in posted here and it just kind of makes me wonder if thats what it really is.
DoobyWho
08-14-2002, 09:24 AM
It seriously is just to help people. I know enough about PHP, I own a very well established design firm, and im currently writting a book about PHP/MySQL. I don't need someone to write simple little scripts for me. Im doing the challenges so that the PHP users of WHT have a chance to test their skills of PHP and try to get some help if they need it. If you think its a scam, then don't participate.
michaeln
08-14-2002, 10:11 AM
Well this is very crude but works if I understand him correctly:
<?
$text = <<<END
<html>
<head>
<title>PHP Challenge 6</title>
</head>
<body>
END;
$check_ereg = "^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)";
$check_ereg .= "([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$";
if(!$form)
{
$text .= <<<END
<form method="post" action="${PHP_SELF}">
<input type="hidden" name="form" value="1">
<p>What is your email address:
<input name="email" type="text" id="email" size="40">
<br>
<br>
Enter three URLS Below:<br>
<input name="url[0]" type="text" id="url[0]" size="40">
<br>
<input name="url[1]" type="text" id="url[1]" size="40">
<br>
<input name="url[2]" type="text" id="url[2]" size="40">
<br>
<br>
Enter three emails addresses to send the above URLS to:<br>
<input name="sendto[0]" type="text" id="sendto[0]" size="40">
<br>
<input name="sendto[1]" type="text" id="sendto[1]" size="40">
<br>
<input name="sendto[2]" type="text" id="sendto[2]" size="40">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
END;
}
else
{
if(!ereg($check_ereg, $email))
{
$text .= "Your email address is invalid";
$error =1;
}
else $text .= "Your message/s have been sent to:<br>\n";
$x = 0;
while($sendto[$x] && !$error)
{
$y = 0;
$mesg = "Please visit the following URLS:\r\n";
while($url[$y])
{
$mesg .= "$url[$y]\r\n";
$y++;
}
if(!ereg($check_ereg, $sendto[$x]))
{
$text .= "The email address $sendto[$x] is invalid<br>\r\n";
}
else
{
$text .= "$sendto[$x]<br>\n";
$mesg .= "\r\nThanks,\r\n$email";
mail($sendto[$x], "Here are some URLS", $mesg, "From: $email <$email>");
}
$x++;
}
}
$text .= "</body></html>";
echo $text;
?>
RRolfe
08-14-2002, 10:25 AM
no problem... it was just a question...
just thought it was strange to be doing on a hosting message board and not a php message board.
Lamont
08-14-2002, 10:50 AM
I think these are great. I'm just learning php and these challenges have helped.
Are there any good php message boards?
RRolfe
08-14-2002, 10:53 AM
i have 2 php message boards but i am not about to post the url's on this board.
that will get ya banned ya know.
They actually arent *that* bad of an idea i guess.
Lamont
08-14-2002, 10:57 AM
whw,
Would you pm me with the urls? I've been looking for a good help site for php.
DoobyWho
08-14-2002, 11:16 AM
michaeln - Goodjob. That's exactly what im talking about. You scripted it a little more extensive then I was expecting , goodjob.
DoobyWho
08-14-2002, 11:17 AM
whw - I do it on this board cause there are alot of designers here and programmers. Im an active member of the WHT community so I thought i'd help out other WHT members.
michaeln
08-14-2002, 11:21 AM
Sorry. Didn't mean to be to extensive... ;)
jolly
08-14-2002, 05:21 PM
I tried to test this script got this error
Parse error: parse error on line 4
michaeln
08-14-2002, 05:38 PM
I am assuming you are reffering to this line:
$text = <<<END
If so you are not running PHP 4.0 or higher you will get a parse error....
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
If you want to see the script work you can see it here: http://www.hostevolve.com/tmp/challenge6.php
EDIT:
I also made it so that you can view that files source by putting this in:
http://www.hostevolve.com/tmp/challenge6.php?view_source=1
UH-Matt
08-14-2002, 08:55 PM
Was this a real challenge ?
If so then i want challenge #8 to be make an opensource fully fledged web hosting control panel identicle to cpanel without any licencing fee ;) :)
michaeln
08-14-2002, 10:56 PM
ok. Is the grand prize a few $k.... ;)
Oh, and would you like that with or without the bugs... ;)
DoobyWho
08-15-2002, 01:39 AM
lol. Why is it that everyone thinks im doing this to jock code ? lol.