Jump to content

Recommended Posts

Good Morning,

 

I am building a system at work with Mysql and PHP with regards to log-in's and submitting information. I need to send the form info to my Database (which works great) but now I have to send the information that was submitted into the Databse to the applicable users email address, this user then has to click a link in the mail to take him/her to continue. I am struggling horribly with the email function..

 

Here is my code that I am using:

 

<?php
$conn = mysql_connect("localhost","root","root");
$db	 = mysql_select_db("mysql",$conn);

?>
<?php
$alloc = $_POST["alloc"];
$allocby = $_POST["allocby"];
$specification = $_POST["specification"];
$reqno = $_POST["reqno"];
$scheme = $_POST["scheme"];
$fromtime = $_POST["fromtime"];
$totime = $_POST["totime"];
$targetdate = $_POST["targetdate"];
$comments = $_POST["comments"];
if($alloc == "s"){
$alloc = 'MHAS002 - AS';
}else if ($alloc == "t"){
$alloc = 'MHMS004 - SM';
}else if ($alloc == "u"){
$alloc = 'MHMN005 - MM';
}else if ($alloc =="v"){
$alloc = 'MHMW005 - MVW';
}else if ($alloc == "w"){
$alloc = 'MHGC001 - GC';
}else if ($alloc == "x"){
$alloc = 'MHGK002 - GDP';
}else if ($alloc == "y"){
$alloc = 'MHLW009 - LW';
}else if ($alloc == "z"){
$alloc = 'MHZP001 - ZP';
};
if($allocby == "a"){
$allocby = 'LM;
}else if ($allocby == "b"){
$allocby = 'User';
}else if ($allocby == "c"){
$allocby = 'Other';
};

$sql	 = "INSERT into manspecification values('$alloc','$allocby','$specification','$reqno','$scheme','$fromtime','$totime','$targetdate','$comments')";
$query = mysql_query($sql);

if(!$query)
echo mysql_error();
else
{
echo "Successfully Inserted<br />";

}

$to = "johnny@johnny.co.za";
$subject = "Specification";
$email = $_POST['Email'];
$message = $_POST['Spec'];
$headers = "From: [email="$johnny@gmail.com"]$johnny@gmail.com[/email]";
$sent = mail($to, $subject, $message, $headers);
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>
<p> </p>
<table border="0" cellspacing="0" cellpadding="3">
<tr><td>
Allocated To:
<td>
<?=$alloc?>
<tr><td>
Allocated By:
<td>
<?=$allocby?>
<tr><td>
Spec Info:
<td>
<?=$type?>
<tr><Td>
Request No:
<td>
<?=$reqno?>
<tr><td>
Scheme:
<td>
<?=$scheme?>
<tr><td>
From Time:
<td>
<?=$fromtime?>
<tr><td>
To Time:
<td>
<?=$totime?>
<tr><td>
Target Date:
<td>
<?=$targetdate?>
<tr><td>
Comments:
<td>
<?=$comments?>
<td>

<td>
</td>

</table>
</form>

<p><A HREF="/manspesifications.html" target="_self"><strong>Go back</strong></A></p>
</body>
</html>


 

I would apprecaite any help with this as this would be the first time that I am working with php and not to mention emails in phph :) *blush* :'( :confused::suicide:

so other than the unterminated string in the assignment of LM to $allocby, the use of short open tags, one of the craziest headers I ever did see, and an $email veriable that you never use, what exactly is it that you are having a problem with? and what exactly is that problem?

if you are trying to send yourself an email with the values that you receive in the form you have to set it up like this

 

just take out the all double quote in the inside the table

and your php syntax

 

[color=#007700][font=Courier New', Verdana, Arial, 'Comic Sans MS][size=3]//so we use the MD5 algorithm to generate a random hash[/size][/font][/color]
[color=#0C3E64][font=Courier New', Verdana, Arial, 'Comic Sans MS][size=3][background=rgb(250, 252, 254)]$random_hash = md5(date('r', time())); [/background][/size][/font][/color]
[color=#000080][font=Courier New', Verdana, Arial, 'Comic Sans MS][size=3][size=2][background=rgb(248, 248, 248)]$headers = "From: [email="$johnny@gmail.com"]$johnny@gmail.com[/email]";[/background][/size][/size][/font][/color]
[color=#007700][font=Courier New', Verdana, Arial, 'Comic Sans MS][size=3]//add boundary string and mime type specification[/size][/font][/color]
[color=#0C3E64][font=Courier New', Verdana, Arial, 'Comic Sans MS][size=3][background=rgb(250, 252, 254)]$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; [/background][/size][/font][/color]

$message = "

[color=#000088]<p>[/color][color=#000000] [/color][color=#000088]</p>[/color]
[color=#000088]<table[/color][color=#000000] [/color][color=#660066]border[/color][color=#666600]=[/color][color=#008800]"0"[/color][color=#000000] [/color][color=#660066]cellspacing[/color][color=#666600]=[/color][color=#008800]"0"[/color][color=#000000] [/color][color=#660066]cellpadding[/color][color=#666600]=[/color][color=#008800]"3"[/color][color=#000088]>[/color]
[color=#000088]<tr><td>[/color]
[color=#000000]Allocated To:[/color]
[color=#000088]<td>[/color]
[color=#666600]<?=[/color][color=#000000]$alloc[/color][color=#666600]?>[/color]
[color=#000088]<tr><td>[/color]
[color=#000000]Allocated By:[/color]
[color=#000088]<td>[/color]
[color=#666600]<?=[/color][color=#000000]$allocby[/color][color=#666600]?>[/color]
[color=#000088]<tr><td>[/color]
[color=#000000]Spec Info:[/color]
[color=#000088]<td>[/color]
[color=#666600]<?=[/color][color=#000000]$type[/color][color=#666600]?>[/color]
[color=#000088]<tr><Td>[/color]
[color=#000000]Request No:[/color]
[color=#000088]<td>[/color]
[color=#666600]<?=[/color][color=#000000]$reqno[/color][color=#666600]?>[/color]
[color=#000088]<tr><td>[/color]
[color=#000000]Scheme:[/color]
[color=#000088]<td>[/color]
[color=#666600]<?=[/color][color=#000000]$scheme[/color][color=#666600]?>[/color]
[color=#000088]<tr><td>[/color]
[color=#000000]From Time:[/color]
[color=#000088]<td>[/color]
[color=#666600]<?=[/color][color=#000000]$fromtime[/color][color=#666600]?>[/color]
[color=#000088]<tr><td>[/color]
[color=#000000]To Time:[/color]
[color=#000088]<td>[/color]
[color=#666600]<?=[/color][color=#000000]$totime[/color][color=#666600]?>[/color]
[color=#000088]<tr><td>[/color]
[color=#000000]Target Date:[/color]
[color=#000088]<td>[/color]
[color=#666600]<?=[/color][color=#000000]$targetdate[/color][color=#666600]?>[/color]
[color=#000088]<tr><td>[/color]
[color=#000000]Comments:[/color]
[color=#000088]<td>[/color]
[color=#666600]<?=[/color][color=#000000]$comments[/color][color=#666600]?>[/color]
[color=#000088]<td>[/color]

[color=#000088]<td>[/color]
[color=#000088]</td>[/color]

[color=#000088]</table>[/color]

";

Edited by ecabrera

Hi,

 

The mail needs to be sent with the information that the "manager" has completed in the one page and then sent to the user to be able to view the information and then click on a link and open the form (where the data is stored in)

 

//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
$headers = "From: $johnny@gmail.com";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
$message = "

 

Do I place the above code before the table I have created ?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.