I am trying to learn php and it sometimes seems like a daunting task. What I am trying to accomplish is to setup a simple user login the users can securely upload files to a server. If the user does not have a login I want to be able to allow them to register, in that they fill out a form, when they submit the form the information from the form is sent via e-mail to several different people, those people then create an account for the user who submitted the form and reply to the user with a user name, password, and a confirmation code of somekind. When the user has received this information they can go finish the registration and be able to log into the website and upload the file. I am going to be using MySQL to keep track of the users and would like to be able to verify their login information with MySQL each time they login. My question would be then, how difficult a task would anyone consider this for someone just starting out learning php? Does it seem like I am trying to do too much or is there an easy way of doing this that i might be missing? Any help would be great. Thanks.
My question would be then, how difficult a task would anyone consider this for someone just starting out learning php?
[/quote]
...is there an easy way of doing this that i might be missing?
[/quote]
[code=php]
<?php
function empMail($empEmail, $userName, $userEmail, $userMessage){
$msg = $userName.' <'.$userEmail.'> has uploaded a file with the following message:' . "n";
$msg .= $userMessage;
$recipient = $empEmail;
$subject = "File Upload Notification";
$mailheaders = "From: ".$userEmail."n";
$mailheaders .= "Reply-To: ".$userEmail;
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
}
function userMail($userName, $userEmail, $userMessage){
$msg = 'Your file was successfully uploaded and your message delivered. Below is the contents of your message:' . "n";
$msg .= 'Your information: '.$userName. '<'.$userEmail.'>' . "n";
$msg .= 'Your message: '.$userMessage;
$recipient = $userEmail;
$subject = "File Upload Notification";
$mailheaders = "From: My Company <[email protected]>"."n";
$mailheaders .= "Reply-To: My Company <[email protected]>";
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
}
//define employee email address array
$empEmails = array("[email protected]", "[email protected]", "[email protected]");
//send email to user and employees if form was submitted correctly
if ($_POST){
if (!empty(strlen($name)) && !empty(strlen($email)) && !empty(strlen($message))){
userMail($userName, $userEmail, $userMessage)."<br /><br />";
foreach ($empEmails AS $empEmail){
empMail($empEmail, $userName, $userEmail, $userMessage)."<br /><br />";
}
header("Location: http://www.someplace.com/success.php");
} else {
print "You must fill in all fields.";
}
}
?>
[/code]
[code=html]
<form id="sendmail" name="sendmail" method="post" action="sendmail.php">
<p>Name:</p>
<input type="text" name="userName" />
<p>E-Mail:</p>
<input type="text" name="userMail" />
<p>Message</p>
<textarea name="userMessage" cols="35" rows="10"></textarea>
<br /><br />
<input name="submit" type="submit" value="Send Mail" />
</form>
[/code]
[code=php]
if ($_POST['submit']){
if (strlen($name) && strlen($email) && strlen($message)){
userMail($userName, $userEmail, $userMessage);
foreach ($empEmails AS $empEmail){
empMail($empEmail, $userName, $userEmail, $userMessage);
}
header("Location: http://www.someplace.com/success.php");
} else {
print "You must fill in all fields.";
}
}
[/code]
<i>
</i><form id="sendmail" name="sendmail" method="post" action="<?php print $PHP_SELF; ?>">
[code=php]
<?php
$empEmail = $_POST['empEmail'];
$userName = $_POST['userName'];
$userEmail = $_POST['userEmail'];
$userMessage = $_POST['userMessage'];
function empMail($empEmail, $userName, $userEmail, $userMessage){
$msg = $userName.' <'.$userEmail.'> has uploaded a file with the following message:' . "n";
$msg .= $userMessage;
$recipient = $empEmail;
$subject = "File Upload Notification";
$mailheaders = "From: ".$userEmail."n";
$mailheaders .= "Reply-To: ".$userEmail;
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
}
function userMail($userName, $userEmail, $userMessage){
$msg = 'Your file was successfully uploaded and your message delivered. Below is the contents of your message:' . "n";
$msg .= 'Your information: '.$userName. '<'.$userEmail.'>' . "n";
$msg .= 'Your message: '.$userMessage;
$recipient = $userEmail;
$subject = "File Upload Notification";
$mailheaders = "From: insert real e-mail info here"."n";
$mailheaders .= "Reply-To: insert real e-mail info here";
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
}
//define employee email address array
$empEmails = array("[email protected]", "[email protected]", "[email protected]");
//send email to user and employees if form was submitted correctly
if ($_POST){
if (strlen($userName) && strlen($userEmail) && strlen($userMessage)){
userMail($userName, $userEmail, $userMessage)."<br /><br />";
foreach ($empEmails AS $empEmail){
empMail($empEmail, $userName, $userEmail, $userMessage)."<br /><br />";
}
header("Location: http://www.somewhere/success.php");
} else {
print "You must fill in all fields.";
}
}
?>
[/code]
[code=php]
if ($_POST['submit']){
if (strlen($userName) && strlen($userEmail) && strlen($userMessage)){
userMail($userName, $userEmail, $userMessage);
foreach ($empEmails AS $empEmail){
empMail($empEmail, $userName, $userEmail, $userMessage);
}
header("Location: http://www.somewhere/success.php");
} else {
print "You must fill in all fields.";
}
}
[/code]
[code=php]
<?php
$empEmail = $_POST['empEmail'];
$userName = $_POST['userName'];
$userEmail = $_POST['userEmail'];
$userMessage = $_POST['userMessage'];
function empMail($empEmail, $userName, $userEmail, $userMessage){
$msg = $userName.' <'.$userEmail.'> has uploaded a file with the following message:' . "n";
$msg .= $userMessage;
$recipient = $empEmail;
$subject = "File Upload Notification";
$mailheaders = "From: ".$userEmail."n";
$mailheaders .= "Reply-To: ".$userEmail;
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
}
function userMail($userName, $userEmail, $userMessage){
$msg = 'Your file was successfully uploaded and your message delivered. Below is the contents of your message:' . "n";
$msg .= 'Your information: '.$userName. '<'.$userEmail.'>' . "n";
$msg .= 'Your message: '.$userMessage;
$recipient = $userEmail;
$subject = "File Upload Notification";
$mailheaders = "From: insert real e-mail info here"."n";
$mailheaders .= "Reply-To: insert real e-mail info here";
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
}
//define employee email address array
$empEmails = array("address1", "address2", "address3");
//send email to user and employees if form was submitted correctly
if ($_POST['submit']){
if (strlen($userName) && strlen($userEmail) && strlen($userMessage)){
userMail($userName, $userEmail, $userMessage);
foreach ($empEmails AS $empEmail){
empMail($empEmail, $userName, $userEmail, $userMessage);
}
header("Location: http://www.tyreeonline.com/main.php");
} else {
print "You must fill in all fields.";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form name="sendmail" method="post" action="<?php print $PHP_SELF ?>" >
<table width="300" border="0" cellspacing="0" cellpadding="3">
<tr>
<td align="right" valign="top">Name:</td>
<td><input type="text" name="userName" value="<?php print ((strlen($userName))? $userName : '')?>" /></td>
</tr>
<tr>
<td align="right" valign="top">Email:</td>
<td><input type="text" name="userEmail" value="<?php print ((strlen($userEmail))? $userEmail : '')?>" /></td>
</tr>
<tr>
<td align="right" valign="top">Message:</td>
<td><textarea name="userMessage" cols="35" rows="5"><?php print ((strlen($userMessage))? $userMessage : '')?></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Send Email" /></td>
</tr>
</table>
</form>
</body>
</html>
[/code]
0.1.9 — BETA 5.22