PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have created a page with the help of this forum only
Now the data is being retrieved successfully.
I would like use the data in a feedback form and it should be sent to the e-mail address specified in the feedback form i.e. I should get the name of the package etc. in the e-mail after the user orders a product from our site.
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("orders",$db);
// display individual record
if (!empty($_GET['id']) && is_numeric($_GET['id'])) {
$sql = "SELECT package, amount, currency, duration FROM spaces WHERE id=".$_GET['id'];
$result = mysql_query($sql, $db) or die(mysql_error().'<p>'.$sql.'</p>');
if (mysql_num_rows($result) == 1) {
$myrow = mysql_fetch_assoc($result);
echo 'Package Name: '.$myrow['package'].'<br />';
echo 'Amount: '.$myrow['currency'].'';
echo ' '.$myrow['amount'].'<br />';
echo 'Duration: '.$myrow['duration'].'<br />';
} else {
// no records found
echo 'There is no record with an ID of '.$_GET['id'];
}
} else {
// no records to display
echo 'Sorry, no records were found!';
}
?>
mail() is the function you are looking for. The code could be very much like what you already have there, put the output in a variable and then mail it to the recipient.
Yeah Mail would work but the problem I am having is that it is retrieving the data from database. Now when I use mail it is not sending the data by e-mail as it is only sending data filled by the user in the form whereas I would like to know the package etc. the user has ordered.
If I've guessed your problem right, you need some hidden fields in the form. The values will be passed to the form processor along with the textarea input.
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("orders",$db);
// display individual record
if (!empty($_GET['id']) && is_numeric($_GET['id'])) {
$sql = "SELECT package, amount, currency, duration FROM spaces WHERE id=".$_GET['id'];
$result = mysql_query($sql, $db) or die(mysql_error().'<p>'.$sql.'</p>');
if (mysql_num_rows($result) == 1) {
$myrow = mysql_fetch_assoc($result);
$message= "Package Name: $myrow['package']<br>
Amount: $myrow['currency'] $myrow['amount']<br>
Duration: $myrow['duration']<br>";
$message_email= "Package Name: $myrow['package']\n Amount: $myrow['currency'] $myrow['amount']\n
Duration: $myrow['duration']\n";
print $message;
mail($rec_email,$subject,$message_email,"From: $sender_email");
}
else {
// no records found
echo 'There is no record with an ID of '.$_GET['id'];
}
} else {
// no records to display
echo 'Sorry, no records were found!';
}
?>
Thanks a lot to every1 who has taken his valuable time to respond to my queries and being patient with me
I have been able to complete the website niftyonline.com upto my satisfaction. I know you guys would be able to suggest a lot of better things after visiting the site and am ready for the brickbats.