On a membership site that I am developing, once the user has logged in, on his profile page there are two simple forms.
The first is diplayed only if the user has his "district" field NULL in the database. If the "district" field contains any information, the first form is replaced by a table displaying data from that district. The purpose of the form is for the user to select his district from a list, and update his account so he can read local information from his district. After he hits submit, the "district" field in the databsase is updated and then he never sees this form again.
The second one is a basic contact form, thru which the user can easily send an email message to the support team if he needs any help. Once the message has been sent, instead of the form, a success message is displayed until the refresh of the page, when the text field comes back to normal and the user can send another message.
I have tested them and they both work fine separately, but the error I am encountering is that when a user with NULL in his "district" field logs in, or whenever his page is refreshed, the second form automatically sends a blank email to the support team, and is allways showing the success message instead of the text input for the message to be written in. I have setup an error when the second form is submitted empty, but despite this, while the first form is showing, with every refresh, a new blank email is being sent...
After the user has submitted the first form an updated his "district", the second form returns to normal and works just fine... I know that there is a conflict, or I forgot to setup some conditions in the code below. Please be kind, take a look and tell me where do you think the error might be. Any help is welcomed.
<? if($row_user['district'] == NULL ):
if(!isset($_POST['submit2']))
{
foreach($row_user as $field => $value)
{
$_POST[$field] = $value;
}
}
$error2 = 0;
if(isset($_POST['submit2'])){
if(isset($_POST['distr']) && ($_POST['distr']==""))
{
$error2 = 1;
$msg_distr="<br /><span class='error'>Select your district</span>";
}
if($error2 == 0)
{
$update = 'UPDATE users SET ';
if(isset($_POST['distr'])) $update .= 'district = '.GetSQLValueString($_POST['distr'], 'text').', ';
$update = substr_replace($update,"",-2);
$update .= 'WHERE id_user = '.$id_user;
mysql_query($update, $conn) or die(mysql_error());
}
}
?>
The HTML code for the first form is
<form action="" method="post" enctype="multipart/form-data" >
<table width="465px" border="0" cellpadding="5" cellspacing="5">
<tr>
<td width="160" valign="middle" align="left">
<span class="style20"><b>Choose District</b> *</span>
</td>
<td valign="top" align="left">
<select name="distr" onChange="sel_distr(this.value)" class="select" >
<option value="">Choose</option>
<option value="District1" <? if($_POST['distr']=="District1") echo "'selected'"?>>District1</option>
<option value="District2" <? if($_POST['distr']=="District2") echo "'selected'"?>>District2</option>
<option value="District3" <? if($_POST['distr']=="District3") echo "'selected'"?>>District3</option>
<option value="District4" <? if($_POST['distr']=="District4") echo "'selected'"?>>District4</option>
<option value="District5" <? if($_POST['distr']=="District5") echo "'selected'"?>>District5</option>
</select>
<?=$msg_distr?>
</td>
</tr>
<tr>
<td >
<input type="submit" name="submit2" class="submit" value="Insert" />
</td>
</tr>
</table>
</form>
<?endif; ?>
The other form is for sending email messages from this page, just by inserting the message and sending it. the user will not need to insert his name or email.
<?php
$error_message=0;
if ($_POST["email"]<>'') {
if(isset($_POST['comment']) && ($_POST['comment']=="")){
$error_message=1;
$er_msg="<br /><span class='error'>You can't send a blank message</span>";
}
if($error_message == 0){
$ToEmail = 'mail#domain';
$EmailSubject = 'New message from '.$row_user['name'].'';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "<b>Name:</b> ".$_POST["name"]."<br/>";
$MESSAGE_BODY .= "<b>Email:</b> ".$_POST["email"]."<br/><br/>";
$MESSAGE_BODY .= " ".nl2br($_POST["comment"])."<br/>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
<div class="success" style="height:60px;">
<b><?=$row_user['name']?>, Your message was sent!</b> <br/>
A member of our team will contact you soon.
</div>
<?php
}
if($error_message == 1){ ?>
<form action="me.html" method="post">
<input name="name" type="hidden" value="<?=$row_user['name']?>" id="name" size="32">
<input name="email" type="hidden" value="<?=$row_user['email']?>" id="email" size="32"> <br/>
<textarea name="comment" cols="45" rows="6" id="comment" class="input" style="width:90%"></textarea><br/>
<input class="submit" type="submit" name="Submit" value="Send">
</form>
<?=$er_msg?>
<?
}
} else {
?>
<form action="me.html" method="post">
<input name="name" type="hidden" value="<?=$row_user['name']?>" id="name" size="32">
<input name="email" type="hidden" value="<?=$row_user['email']?>" id="email" size="32"> <br/>
<textarea name="comment" cols="45" rows="6" id="comment" class="input" style="width:90%"></textarea><br/>
<input class="submit" type="submit" name="Submit" value="Send">
</form>
<?php
};
?>
Alright, I think this is a minor mistake and you are getting confused because of the too many error counter flags.
Try changing this:
if($error_message == 0){
to:
if($error_message == 0 && $row_user['district'] != NULL){
Related
This question already has an answer here:
How to validate form in php
(1 answer)
Closed 8 years ago.
Anyone please help me on how to validate a form? I have the code, it is working ok..but I found that after I hit the submit button & php shows the errors, there is an input field, asking the user to answer the math Ques..when I enter the answer, then hit submit button again, it just says mail successfully sent, but other fields are still empty. Any ideas how to fix it. Also, the php value in the answerbox input tags, is not saving the text in box, it disappears. by the way, I got some help from other users, i'm a noob in php, so if you don't mind please explain.
Thanks for your time!
<form name="contact" action="formtest.php" method="post">
<label for="YourName">Your Name:</label>
<input type="text" name="name" class="required" value="<?= isset($_POST['name']) ? $_POST['name'] : '' ?>" />
<label for="YourEmail">Your Email:</label>
<input type="text" name="email" class="required" value="<?= isset($_POST['email']) ? $_POST['email'] : '' ?>"/>
<label for="Subject">Subject:</label>
<input type="text" name="subject" class="required" value="<?= isset($_POST['subject']) ? $_POST['subject'] : '' ?>" />
<label for="YourMessage">Your Message:</label>
<textarea name="message" class="required"><?= isset($_POST['message']) ? $_POST['message'] : '' ?></textarea>
<p class="c3">10 + 5 =<input type="text" name="answerbox" id="answerbox" "<?= isset($_POST['answerbox']) ? $_POST['answerbox'] : '' ?>"/></p>
<fieldset>
<input type="submit" name="submit" id="submit" value="Send" class="required"/>
<input type="reset" id="reset" value="Reset"/>
</fieldset>
<?php
if(isset($_POST['submit'])){
$name = trim($_POST["name"]);
$email = trim($_POST["email"]);
$subject = trim($_POST["subject"]);
$message = trim($_POST["message"]);
$answerbox = trim($_POST["answerbox"]);
if(empty($_POST['name'])){
print "<div class='formerrors'><li>Please type your name.</li></div>";
}
else {
if (ctype_alpha($name) === false) {
print "<div class='formerrors'><li>Your name only should be in letters!</li></div>";
}
}
if(empty($_POST['email'])){
print "<div class='formerrors'><li>You've forgot to type your email address.</li></div>";
} else{
if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){
print "<div class='formerrors'><li>Your email is not valid, please check.</li></div>";
}
}
if(empty($_POST['subject'])){
print "<div class='formerrors'><li>Please type a subject.</li></div>";
}
if(empty($_POST['message'])){
print "<div class='formerrors'><li>You've forgot to type your message.</li></div>";
}
if(empty($_POST['answerbox'])){
print "<div class='formerrors'><li>Please answer the math question.</li></div>";
}
else {
if($answerbox != 15){
print"<div class='formerrors'><li>Answer is not correct.</li></div>";
}
else{
$headers = 'From: '.$email. "\r\n" .
'Reply-To: '.$email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail('me#mymail.me',$subject,$message,$headers);
print "<div class='formerrors'><li>mail succesuffully sent</li></div>";
}
}
}
?>
</form>
Try placing your php code above the html as it is php setting the values of the variables, and you are calling them before they are set.
It is best practice to have php code at the top of the file, and then html below it, or even have the php on a separate file, but include it at the top.
Also I find it better to create an array of errors, and then if the array count is 0, then perform the action (send email) else call the error of arrays within the html, not the php. Then you can choose where to display it on the page, and style it accordingly.
Change your form action to
<?php $PHP_SELF; ?>
So it has to be
<form name="contact" action="<?php $PHP_SELF; ?>" method="post">
For the other issue you must place your code above the form.
I'm very new to PHP coding.
I've done tons of research to try and help me. As you can imagine I've gotten tons of material for help. The problem is when I'm trying to put it all together.
Specifically here is my problem. I've come across:
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "e-Mail is Valid";
} else {
echo "Invalid e-Mail";
}
But I have no idea how to implement it. As it stands now the validator checks the fields before the user has time to imput them..... I'm desperate
I'm sure the solution is really simple, but I've spent hours on this and am really desperate for this problem to be solved already.
Here's a link to the page
Here is the code for the page:
<!DOCTYPE html>
<head>
<meta charset='utf-8'>
<title>AWalsh Photography - Contact Me</title>
<link href="style/main_page.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="email_container">
<h1 class="email_head"> Contact Andrew walsh Photography</h1>
<form id="email_form" name="email_form" method="post">
<table>
<tr>
<td><label for="fname">First Name:</label>
</td>
<td><input type="text" name="fname_input" id="fname_input" /><br>
</td>
</tr>
<tr>
<td><label for="lname">Last Name:</label>
</td>
<td><input type="text" name="lname_input" id="lname_input" /><br>
</td>
</tr>
<tr>
<td><label for="email_input">Your Email:</label>
</td>
<td><input type="text" name="email_input" id="email_input" /><br>
</td>
</tr><tr>
<td><label for="email_conf">Re-enter Email:</label>
</td>
<td><input type="text" name="email_conf" id="email_conf" /><br>
</td>
</tr><tr>
<td>
<label for="message_input">Message </label>
</td><td>
<textarea rows="8" cols="45" id="message_input" name="message_input"></textarea>
</td></tr><tr><td></td>
<td>
<input id="submit"type="submit" value="submit" name="submit"/>
</td></tr>
</table>
</form>
<?php
if($_POST['email_imput'] == $_POST['email_conf']){
//stuff to do on success
echo '<h1>Success!!</h1>';
} else {
//stuff to do on failure
echo '<h1>Sorry, The emails you entered do not match</h1>';
}
$email_imput = $_POST['email_imput'];
if (filter_var($email_imput, FILTER_VALIDATE_EMAIL)) {
echo $email_imput . ' is a valid email address.';
} else {
echo $email_imput . ' is not a valid email address.';
}
$message_imput = $_POST['message_imput'];
$msg = "Email address: $email_imput \n" . "Message: $message_imput";
$to = 'myemail#gmail.com ';
$subject = 'AWP_email';
if (filter_var($email_imput)){
mail($to, $subject, $msg, $email);
}
if (mail($to, $subject, $msg, $email)) {
echo("<p>Message successfully sent! Thanks for submitting your message. We will reply to you as soon as possible</p>");
} else {
echo("<h1>Sorry, There was an error in your imput. Please try again.</h1>");
}
?>
<span class="error"><?=$error;?></span>
<form method="post" action="">
<h1> There was an error with your post</h1>
</form>
</div>
</div>
</body>
</html>
Any input would be amazing. Thank you.
You could add a hidden field into the form and check it's value when it's time to send the email.
if (isset($_POST["some_hidden_field"])) {
// put form validation and sending email here
}
else {
// print the form
}
You should first check whether the page has been submitted or not. You might want to try if ($_SERVER['METHOD'] == 'POST') before making any validations
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Every time i click the submit button the page re-directs.
how can i set it up so that the page does not re-direct and it runs the server side code staying on the current page and echoing above my form?
HTML Code:
<form name="contact_form" method="post" action="mail.php">
<table border="0">
<tbody class="Form">
<tr>
<td>
<label for="NameInput">Your Name:<font color="#FF0000">*</font></label>
<input autofocus="autofocus" placeholder="John Doe" id="NameInput" name="NameInput" required="required" />
</td>
</tr>
<tr>
<td>
<label for="CompanyName">Your Company:<font color="#FF0000">*</font></label>
<input required="required" placeholder="Warner bros." id="CompanyName" name="CompanyName" />
</td>
</tr>
<tr>
<td>
<label id="PhoneNumber" name="PhoneNumber">Phone: </label>
<input placeholder="888-888-8888" id="PhoneNumber" name="PhoneNumber"/>
</td>
</tr>
<tr>
<td>
<label id="Email" name="Email">Email:<font color="#FF0000">*</font></label>
<input required="required" placeholder="johndoe#gmail.com" id="Email" name="Email" type="email" />
</td>
</tr>
<tr>
<td>
<label for="Website">Website: </label>
<input placeholder="https://" id="Website" name="Website" />
</td>
</tr>
</tbody>
</table>
<br/>
<br/>
<br/>
<br/>
<p><strong>What interests you, broadly speaking?</strong></p>
<br/>
<p><input id="WebDesignCheckbox" name="WebDesignCheckbox" type="checkbox">Web Design/Development</input></p>
<input id="SocialMediaCheckbox" name="SocialMediaCheckbox" type="checkbox">Social Media</input>
>
<input id="MobilePresence" name="MobilePresence" type="checkbox">Mobile Presence</input>
<input id="OnlineAdvertising" name="OnlineAdvertising" type="checkbox">Online Advertising</input>
<input id="SEOCheckbox" name="SEOCheckbox" type="checkbox">Search Engine Optamization</input>
<p><input id="ecommerceCheckbox" name="ecommerceCheckbox" type="checkbox" >eCommerce</input></p>
<br/>
<label for="comments">Your Ideas to Life?</label><br/>
<textarea placeholder="How can we help you?" id="comments" name="comments" style="margin: 2px; height: 137px; width: 437px;"></textarea></td></tr><br/>
<tr>
<td><input type="submit" id="Submit" name="Submit" value="Submit" align="middle" /></td>
</tr>
<p id="req-field-desc"><span class="required">*</span> indicates a required field</p>
</form>
PHP Script mail.php:
<?php
if( isset($_POST) ){
//form validation vars
$formok = true;
$errors = array();
//sumbission data
$ipaddress = $_SERVER['REMOTE_ADDR'];
$date = date('d/m/Y');
$time = date('H:i:s');
//form data
$NameInput = $_POST['NameInput'];
$CompanyName = $_POST['CompanyName'];
$PhoneNumber = $_POST['PhoneNumber'];
$Email = $_POST['Email'];
$Website = $_POST['Website'];
$WebDesignCheckbox = $_POST['WebDesignCheckbox'];
$SocialMediaCheckbox = $_POST['SocialMediaCheckbox'];
$MobilePresence = $_POST['MobilePresence'];
$OnlineAdvertising = $_POST['OnlineAdvertising'];
$SEOCheckbox = $_POST['SEOCheckbox'];
$ecommerceCheckbox = $_POST['ecommerceCheckbox'];
$comments = $_POST['comments'];
//form validation
if(empty($NameInput)){
$formok - false;
$errors[] = "You have not entered a name.";
}
if(empty($CompanyName)){
$formok = false;
$errors[] = "You have not entered a company name.";
}
if(empty($Email)){
$formok = false;
$errors[] = "You have not entered an email address.";
}
//send email if checks out
if($formok){
ini_set("sendmail_from","keeano#doodleinc.co");
/*$headers="From: Contact Page: {$Email}" . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";*/
$emailbody = "
<p>Time: {$time} \n {$date}</p>
<p>You are recieving this from your websites contact form.</p>
<p><strong>Contacts Name: </strong> {$NameInput}</p>
<p><strong>Companys Name: </strong> {$CompanyName}</p>
<p><strong>Phone Number: </strong> {$PhoneNumber}</p>
<p><strong>Email: </strong> {$Email}</p>
<p><strong>Website: </strong> {$Website}</p>
<p><strong>Web Design Checkbox: </strong> {$WebDesignCheckbox}</p>
<p><strong>Social Media Checkbox: </strong> {$SocialMediaCheckbox}</p>
<p><strong>Mobile Presence: </strong> {$MobilePresence}</p>
<p><strong>Online Advertising: </strong> {$OnlineAdvertising}</p>
<p><strong>SEO Checkbox: </strong> {$SEOCheckbox}</p>
<p><strong>eCommerce Checkbox: </strong> {$ecommerceCheckbox}</p>
<p><strong>Comments: </strong> {$comments}</p>
<p><strong>Extra Data Obtained:</strong>\n Users IPAddress: {$ipaddress}</p>
";
mail("keeano#doodleinc.co", "Contacts Page Enquiry", $emailbody);
echo('<p style="font-weight: bold; color: #709900"><em>Thank you for contacting doodle Inc., someone will contact you within 48 hours.</em></p>');
}
}
I would simply like to get this to create a label at the top of the Form saying "Thank you, someone will be in touch with you within 48 hours."
If someone can help me that would be great as well as detail the explanation so i never run into this problem again.
The thing is you have mail.php as your action for the form tag.
you could just leave it blank, then the form will post to the same page (contact.php)
To get the functionality working on that page you could include your mail.php file before the form, so that the errors are displayed on that same page.
just a require("mail.php"); at the top of the code will do.
You could look at doing a javascript event on the submit button. Then use json and ajax to process your form etc, return a success/fail message, and insert into where the form was. This will not 'redirect' the user to a different page, the form will get replaced by a success message.
<form method="get" action="" onsubmit="jsquickcomp(this); return false;" > // or something like this for your form heading.
Then you js function....
function jsquicksub(po_form) {
if (gb_ajaxbusy)
return false;
gb_ajaxbusy = true;
var lo_request = {};
lo_request.n = $(po_form).find('#sub-firstname').val();
lo_request.e = $(po_form).find('#sub-email').val();
// etc etc
$(po_form).fadeTo(200, 0.3);
$.getJSON('/mail.php', lo_request, function(po_result) { // this is your mail.php which performs all the php side of the form stuff
gb_ajaxbusy = false;
$(po_form).fadeTo(0, 1);
if (!po_result.success) {
alert(po_result.content); // has an alert box for error message. Can change it for anything
return false;
}else{
setTimeout(function() {
$.modal.close();
}, 2500);
}
$(po_form).replaceWith(po_result.content); // replaces the form with the success message
});
}
Then in your mail.php
// function gets passed values after validation and returns a message to the user on screen
function jsonreturn($pb_success, $ps_content = null) {
$lo_result = (object) array('success'=>$pb_success, 'content'=>$ps_content);
ob_clean();
echo json_encode($lo_result);
exit;
} // end jsonreturn()
// use $_GET to get all the values you have send through from your js file
// validate the data and do whatever you want to do with it
// these return the message that will replace the form
jsonreturn(true, 'Success!'); // for success
jsonreturn(false, 'Fail'); // for fail
Hope that makes some sense?
I'm working on a very simple, very easy contact form and when i did it on a separate page it worked perfectly, but when i added it to the current website it can't get the $_POST i don't know why. here are the codes
$to ="enter email here";
$name = $_POST["name"];
$email = $_POST["email"];
$header = "From " . $name;
$message = $_POST["message"];
$content = "From: ". $name ."<br /> Email: " . $email ."<br /> Message: " . $message;
if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
echo "illegal email";
}
else
{
if (!empty($name) && !empty($message)){
mail($to, $header, $content);
echo"sent <br />";
echo $content;
}else
{
if(empty($email))
{
echo "your email is empty";
}
elseif(empty($name))
{
echo "please enter your name";
}
elseif(empty($message)){
echo "can't send empty messages";
}
}
}
html
<form method="post" action="mail.php">
<table>
<tr>
<td>
Name:
</td>
<td>
<input type="text" name="name" />
</td>
</tr>
<tr>
<td>
Email:
</td>
<td>
<input type="text" name="email"/>
</td>
</tr>
<tr>
<td>
Subject:
</td>
<td>
<input type="text" name="subject"/>
</td>
</tr>
<tr>
<td>
Message: <br /><br/><br/>
</td>
<td>
<textarea style="resize:vertical;" name="message"></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit"/>
</td>
</tr>
</table>
</form>
thanks in advance and sorry if its a repeat
Check that the PHP is actually executing by adding something like this to the top:
echo "Testing PHP...";
If you do not see that output after submitting a form, check that you are posting the form to the right file. For example, you might need to use:
<form method="post" action="/mail.php">
or
<form method="post" action="/php/mail.php">
...code depending on your website structure.
It's certainly not $_POST that's broken, so it must be something either server related or an error in your code.
Do you have any other PHP on the website your importing the form to? If so you need to make sure that it isn't affecting it in any way.
One more thing to check, it has been reported that a PHP update accidently changed the upload limit size from "8M" to "10MB". Have a scan through your php.ini file and make sure that their isn't any unwanted "MB" instead of "M" in your upload limit.
One final suggestion I can give if you still haven't found the cause after this, is try using:
<?php var_dump($_POST); ?>
which should reveal what's really there.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to send email with attachment using PHP?
hello iam new to php please let me know is any script or link for ( php script to send mail with file multiple attachments) and the html form also to how to connect this form or any inbuilt script so that i can upload to my server.
i already try in many ways by coping the codes and pasting them and changing there path but still it get many errors so please let me know if there inbuilt script easily upload to my server
<?php
if($_GET['name']== '' || $_GET['email']=='' || $_GET['email']=='' || $_GET['Message']=='' )
{
?>
<form action="check3.php" method="get" name="frmPhone">
<fieldset>
<legend style="color:#000">Contact </legend>
<table width="100%">
<tr>
<td width="29%">
<label for="name" <?php if(isset($_GET['Submit']) && $_GET['name']=='') echo "style='color:red'"; ?>>Name* </label> </td> <td width="71%">
<input id="name" name="name" type="text" style="width:50%" value=" <?php echo $_GET['name']; ?>"/> </td> </tr> <tr> <td>
<label for=" email" <?php if(isset($_GET['Submit']) && $_GET['email']=='') echo "style='color:red'"; ?>>Email* </label> </td> <td>
<input id="email" name="email" type="text" style="width:50%" value=" <?php echo $_GET['email']; ?>"/> </td> </tr>
</table>
</fieldset>
<fieldset>
<legend style="color:#000">Inquiry </legend>
<table width="100%">
<tr> <td width="41%" valign="top">
<label for="Message" <?php if(isset($_GET['Submit']) && $_GET['Message']=='') echo "style='color:red'"; ?>>Message*</label> </td> <td width="59%"> <textarea name="Message" rows="5" style="width:90%" id="Message"> <?php echo $_GET['Message']; ?> </textarea> </td><div align="center">Photo
<input name="photo" type="file" size="35" />
</div></td>
</tr>
<tr>
<input name="Submit" type="submit" value="Submit" />
</form> </td> </td>
</form>
</tr>
<?php
}
else
{
$to = 'abhi326#gmail.com';
$subject = 'Customer Information';
$message = '
Name: '.$_GET['name'].'
Email Address: '.$_GET['email'].'
Message: '.$_GET['Message'];
$headers = 'From:'.$_GET['email'];
mail($to, $subject, $message, $headers);
$connection=mysql_connect("db2173.perfora.net", "dbo311409166", "malani2002") or die(mysql_error());
$query = mysql_query("INSERT INTO `feedback` ( `name` , `email` , `Message` , `photo` ) VALUES ('".$_GET['name']."', '".$_GET['email']."', '".$_GET['Message']."')");
define ("MAX_SIZE","75");
if(isset($_FILES['photo']['name']) && $_FILES['photo']['name']<>"") {
$typ = $_FILES['photo']['type'];
if($typ == "image/g if" || $typ == "image/png" || $typ == "image/jpeg" || $typ == "image/pg if" || $typ == "image/ppng" || $typ =="image/JPEG")
{
$uploaddir = "contacts/";
$uploadimages = $uploaddir.basename($_FILES['photo']['name']);
if(move_uploaded_file($_FILES['photo']['tmp_name'], $uploadimages)) {
echo "File successfully copied";
$sql="INSERT INTO contacts (Photo, Beschrijving)
VALUES ('$uploadimages',
'$_POST[images]')";
if (!mysql_query($sql,$con)) {
die('Error: ' . mysql_error());
mysql_close($con);
}
}
else {echo "Copy unsuccessful"; }
}
else {
echo "Incorrect file type";
}
}
else {
echo "No file selected";
}
echo "Thank you! ";
}
?>
thanks and regards
abhi
The script you're lookingfor is phpMailer.
This script can be downloaded and is easily added to your PHP programs. It makes sending emails from PHP extremely easy, including adding attachments.
Hope that helps.