PHP - Menu List Sendmail .php
Hi I am having a problem with the code below I am using to send a simple php email form.
I am not that advanced with php but I want to add a drop down menu to a form I created and not sure how to get get the message (warning not completed) in the field - if(empty($visitortitle)) { - to accept or not to accept? This is the code in the form: <td align="left"><select name="visitortitle"> <option>Please Select</option> <option>Mr</option> <option>Mrs</option> <option>Miss</option> <option>Ms</option> <option>Dr</option> </select> This is the code I have got in the sendemail: if(empty($visitortitle)) { echo "<h2><br /><br /><br /><br />Please hit the back button and enter the title drop down box correctly<br />before you try submitting the form again.</h2>\n"; die ( '<a href="forum.html">click here go back and try again</a>' ); } How can I get this code to recognise that a <option></option> has been selected? Any help would be appreciated. Thanks Gary Similar TutorialsI am getting an error on a form which sends an email if the form is succesfull. I think there may ne an issue with the sendmail function. I am using a hosting company and not sure if sendmail is something that has to be enabled in the .ini file. Is there any way to check without getting the hosting company involved? This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=359470.0 Hi, my webhost has the mail() function disabled. However, my emails are hosted in the offices sever and can't use smtp due to the firewall blocking it. How do I setup sendmail instead of the mail(). I tried googling this but keep coming across to the mail() functions. I wrote this code and I keep getting Parse error: syntax error, unexpected $end in the last line <?php $subject = 'Registration'; $fname = $_POST['fname']; $lname = $_POST['lname']; $address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $phone = $_POST['phone']; $email = $_POST['email']; $mortgage = $_POST['mortgage']; $comments = $_POST['comments']; if($fname == ""){ echo 'Please fill out a First Name'; exit(); }elseif($lname == ""){ echo 'Please fill out a Last Name'; exit(); }elseif($address == ""){ echo 'Please fill out an Address'; exit(); }elseif($city == ""){ echo 'Please fill out a City'; exit(); }elseif($state == ""){ echo 'Please fill out a State'; exit(); }elseif($zip == ""){ echo 'Please fill out your Zip Code'; exit(); }elseif($phone == "") { echo 'Please fill out a Telephone Number'; exit(); }elseif($mortgage == "") { echo 'Please fill out a Mortgage Company'; exit(); }else{ $to = 'amphit@live.com'; $mailfrom = '$email'; $header = "from: $fname $lname <$mail_from>"; $detail = "First name - $fname <br> Last Name - $lname <br> Address - $address <br> City - $city <br> State - $state <br> Zip - $zip <br> Phone - $phone <br> Email - $email <br> Mortgage - $mortgage <br> Comments - $comments"; $send_mail=mail($to,$subject,$detail,$header); if($send_mail){ echo "We've recived your contact information"; } else { echo "ERROR"; } ?> Hi guys I'm seriously stressing hard about this. I seem to have written everything properly but my contact form just won't send an e-mail and update the status on my webpage. I fill out the details on my contact form and my status text stays on "Email is sending...". I'd REALLY REALLY appreciate any help you could toss my way. Thanks a ton! sendmail.php <?php $name = @trim(stripslashes($_POST['name'])); $from = @trim(stripslashes($_POST['email'])); $subject = @trim(stripslashes($_POST['subject'])); $message = @trim(stripslashes($_POST['message'])); $to = 'myemail@gmail.com';//replace with your email $headers = array(); $headers[] = "MIME-Version: 1.0"; $headers[] = "Content-type: text/plain; charset=iso-8859-1"; $headers[] = "From: {$name} <{$from}>"; $headers[] = "Reply-To: <{$from}>"; $headers[] = "Subject: {$subject}"; $headers[] = "X-Mailer: PHP/".phpversion(); mail($to, $subject, $message, $headers); die(); ?> main.js //Contact Form var form = $('#contact-form'); form.submit(function(event){ event.preventDefault(); var form_status = $('.form-status'); $.ajax({ url: $(this).attr('action'), beforeSend: function(){ form_status.find('.form-status-content').html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn(); } }).done(function(data){ form_status.find('.form-status-content').html('<p class="text-success">Thank you for contact us. As early as possible we will contact you</p>').delay(3000).fadeOut(); }); }); contact.html <form class="form-horizontal" id="contact-form" role="form"> <div class="form-group form-status"> <div class="col-sm-offset-2 col-sm-6"> <div class="form-status-content"> </div> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-6"> <input type="text" name="name" class="form-control input-lg" placeholder="Name" required="required"> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-6"> <input type="email" name="email" class="form-control input-lg" placeholder="Email" required="required"> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-6"> <input type="text" name="subject" class="form-control input-lg" placeholder="Subject" required="required"> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-8"> <textarea name="message" rows="6" class="form-control input-lg" placeholder="Message" required="required"> </textarea> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-8"> <button type="submit" class="btn btn-lg btn-transparent">Submit</button> </div> </div> </form> Edited February 27, 2020 by g0dtier Hello, I am using the Pear Mail and Mail_Mime packages to send SMTP authenticated HTML formatted emails. I was successfully sending emails when I started getting the following error: sendmail: 451 Internal Error I check out the sendmail logs at /var/log/mail.log but that only says the same thing. I am running Linux-Ubuntu and sending emails from an address on a remote server (godaddy hosted). The interesting thing is that this exact same code will run to completion and fail. Any thoughts? Anyone with Pear Mail experience, is there any way to end the SMTP session, maybe that is the problem. I also think an issue might be that the server thinks my IP is sending too many emails, any way to provision against that? Thanks for any insight and please let me know if other information might be helpful to debug this. Had the following code working for months and now its not working anymore??? I dont't think the code is the correct way to do it but it did work, Can someone please look at it or give me the correct code. All I am trying to do is take the data from the form and email it to an email address and cc the user that filled out the form. I would like to add a bcc in the future. Here is my current code <?php $email = $_POST['EMAIL']; $mailto = "user@domain.com, user@domain.org"; $mailhead = "FROM: LOI<user@domain.org>"."\r\n"; $mailhead .= "Reply-To: user@domain.org"."\r\n"; $mailhead .= "CC: ".$email; $mailbody = "Values submitted from LOI:\n"; while (list($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; } mail($mailto, $mailsubj, $mailbody, $mailhead); header("LOCATION: letter.html"); ?> (my file structure is the following. inquiry.html has a form and the submit button goes to letter.php(code above) then it directs to letter.html) Thanks Trevor Here is my sendmail.php code: <?php //capture form data in name/value structure //ie. fName = "Pouya" $fNameVar = $_POST['fName']; $lNameVar = $_POST['lName']; $emailVar = $_POST['email']; $commentVar = $_POST['comment']; $telVar = $_POST['tel']; //echo "First Name is {$fNameVar}, last name is {$lNameVar}, email is {$emailVar} and comment is {$commentVar}"; // The e-mail function requires 3 types of info // A. Destination e-mail // B. Subject line // C. Body of your message // D. E-mail of sender mail("puya.turkiyan@gmail.com", "Message from my New Media Sources", $commentVar, "From:$emailVar"); //echo "Thank you $fNameVar" header("Location:thankyou.php"); ?> In the mail section I can only send 2 variables. As soon as I add the third it doesn't even send anything to my e-mail. Please help, its driving me crazy. Here is my table page: <?php include "header.html"; ?> <div id="templatemo_menu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="about.php">About Us</a></li> <li><a href="services.php">Services</a></li> <li><a href="gallery.php">Gallery</a></li> <li><a href="#">Blog</a></li> <li><a href="contact.php" class="current">Contact Us</a></li> </ul> </div> <!-- end of templatemo_menu --> <?php include "socialmedia.html"; ?> <div class="cleaner"></div> </div> <div class="cleaner"></div> </div> <!-- end of header --> </div> <!-- end of header_wrapper --> <div id="templatemo_content_wrapper"> <div id="templatemo_content"> <h1>Contact Information</h1> <p>Here are a few ways to get a hold of us. The best way would be e-mail or phone but you can also use other methods such as <a href="http://www.twitter.com/pehlavoon"><img src="images/twitter-1.png" alt="twitter" width="30" height="30"/> </a> or <a href="http://www.facebook.com/puya.turkiyan"><img src="images/facebook-1.png" alt="facebook" width="30" height="30"/></a> to contact us.</p> <div class="cleaner_h50"></div> <div class="two_column float_l"> <div id="contact_form"> <h2>Contact Form</h2> <fieldset> <legend>Contact me</legend> <form action="sendmail.php" method="post"> <ul> <li><label for="fName">First Name: </label> <input type="text" name="fName" value="" id="fName" /></li> <li><label for="lName">Last Name: </label> <input type="text" name="lName" value="" id="lName" /></li> <li><label for="email">E-mail: </label> <input type="text" name="email" value="" id="email" /></li> <li><label for="tel">Phone number: </label> <input type="text" name="tel" value="" id="tel" /></li> <li><label for="comment">comment: </label> <textarea cols="5" rows="5" name="comment" id="comment"></textarea></li> <li><input type="submit" value="Send" /></li> </ul> </form> </fieldset> </div> </div> <div class="two_column float_r"> <h6>Contact our development team:</h6> Located in Vancouver Canada<br /> <strong>Email:</strong> <a href="mailto:puya.turkiyan@gmail.com">puya.turkiyan@gmail.com</a> <p><strong>Phone:</strong> 1+778-991-7892</p> <div class="cleaner_h60"></div> <h6>Contact our Account manager</h6> Located in Downtown Vancouver Canada<br /> <strong>Email:</strong> <a href="mailto:richardboulier@gmail.com">richardboulier@gmail.com</a> <p><strong>Phone:</strong> 1+778-230-1084</p> </div> <div class="cleaner"></div> </div> <!-- end of content --> </div> <!-- end of content_wrapper --> <?php include "footer.html"; ?> Take a look and see if you can help me. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=313491.0 I Have the following issue and I spend my whole day looking for it. I have a database with a simple admin where I add/delete values. The database structure is the following: id, zip, email The database is called zipdatabase Here is the mailing part: Code: [Select] //headers $headers = "From: <$Email>"; $headers .= "\r\nBcc: <$Bcc>\r\n\r\n"; // send email $success = mail($EmailTo, $Subject, $Body, $headers);The variable $Bcc must come from the database. I am really ignorant so I only got to a point on how to echo the results I need (and this works): Code: [Select] $query = "SELECT email FROM zipdatabase WHERE zip = '$ZIP'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo "{$r['email']}, "; } ?> For a zip I get more than one result so when I tried using this Code: [Select] $query = "SELECT email FROM zipdatabase WHERE zip = '$ZIP'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $Bcc = "{$r['email']}, "; } echo "Bcc" ?> It only gives me one result. What I noticed is I have 2 issues: - I can't extract the BCC from the database - I don't know how to add more email addresses to the bcc field, I only managed to add more addresses to the $Emailto like: Code: [Select] $EmailTo = "address1@domain.com, address2@domain.com"; $Bcc = "address3@domain.com"; All these variables are defined by a webform and it works flawlessly except the database problem: Code: [Select] $Name = Trim(stripslashes($_POST['Name'])); $Phone = Trim(stripslashes($_POST['Phone'])); $ZIP = Trim(stripslashes($_POST['ZIP'])); $Email = Trim(stripslashes($_POST['Email'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=contacterror.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Phone: "; $Body .= $Phone; $Body .= "\n"; $Body .= "ZIP: "; $Body .= $ZIP; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; Sorry for my ignorance and hope someone here can help. The webform works perfectly except the bcc from the database part. I've got PHP setup on Ubuntu with MySQL. I've got sendmail installed but for some reason I can't get mail() to work. Does anyone have good guidelines for getting this setup properly? Hi all, i want my list/menu field values to come from my database. how can i accomplish that? thanks i did Code: [Select] <select name="select"> <option value="0">--select below--</option> <option value="1">Me</option> <?php require_once '../konnect/konex.php'; $result = mysql_query("SELECT * FROM is_clients"); while($row = mysql_fetch_array($result)) { echo "<option value ='2'>".$row"['name']</option>"; echo "<br />"; } ?> </select> I got a tab menu, where the user choose his category and a list of sub categories appear. Personally I like the old fashion way, where everything listed like in craiglist.com ... How can I turn the following tab menu, into a simple 3 column list? <!--CATEGORIES--> <div id="selCategories"> <div class="slidetabsmenu menu_fix"> <ul> <?php if(isset($groups) and $groups->num_rows()>0) { $i=0; foreach($groups->result() as $group) { ?> <li id="gr<?php echo $i;?>" class="<?php if($i == '0') echo "selected"; ?>"><a href="javascript:;" onclick="getCat('<?php echo $i ?>','<?php echo $groups->num_rows ?>',<?php echo $group->id;?>);"><span><?php echo $group->group_name;?></span></a></li> <?php $i++;} } ?> </ul> </div> <div class="clsInfoBox"> <div class="block"> <div class="grey_t"> <div class="grey_r"> <div class="grey_b"> <div class="grey_l"> <div class="grey_tl"> <div class="grey_tr"> <div class="grey_bl"> <div class="grey_br"> <div class="cls100_p"> <h4><span class="clsCategory"><?php echo $this->lang->line('CATEGORIES');?></span></h4> <div class="clsCategoryList clearfix" id="catInner"> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <!--END OF CATEGORIES--> Your tips, directions, and support is highly appreciated. Im using dreamweaver, and I have a simple list menu that is linked to a dynamic source in my database. I cannot figure out how to create an action when they select something from the list menu. I suppose that it would have to be passed through the browser somehow. Im not very code fluent, but I try. If you know to accomplish this using dreamweaver cs4 or hard coding, I would appreciate it. I want this: When you click on an item it will bring up all the data pertaining to that particular record. My code: Code: [Select] <form id="form1" name="form1" method="post" action=""> <label for="customerlist">Select your customers</label> <p><label for="customers"></label> <select name="customers" id="customers"> <option value="None">None</option> <?php do { ?> <option value="<?php echo $row_Customers['name']?>"><?php echo $row_Customers['name']?></option> <?php } while ($row_Customers = mysql_fetch_assoc($Customers)); $rows = mysql_num_rows($Customers); if($rows > 0) { mysql_data_seek($Customers, 0); $row_Customers = mysql_fetch_assoc($Customers); } ?> </select> <input type="submit" name="Go" id="Go" value="Go" /> Hi there, Im trying to build a drop down menu that has an if statement to determine the results, heres the code below: Code: [Select] <option value="<?php echo $row_Planet['PlanetName']?>"<?php if ($row_Planet['PlanetName'] == 'Mon Calamari'){ echo"Yavin"; echo"Denab";) ?><?php echo $row_Planet['PlanetName']?></option> Im really unsure of the syntax. If you could help that would be ace! Thanks First off, I am new to PHP, and want to learn it, but it seems very complicated. Where do I begin? I found a script online for a contact form and I am having trouble making it work for my needs. I wanted to include a phone number field in the email message. This is what I have so far for the PHP, but it does not include the phone field in the body of the message. Everything else works fine. Apologize in advance if this message has been posted many times before. <?php $post = (!empty($_POST)) ? true : false; if($post) { include 'functions.php'; $name = stripslashes($_POST['contactname']); $email = trim($_POST['email']); $subject = "New Message from your website"; $message = stripslashes($_POST['message']); $phone = stripslashes($_POST['phone']); $error = ''; // Check name if(!$name) { $error .= 'Please enter your name.<br />'; } // Check email if(!$email) { $error .= 'Please enter an e-mail address.<br />'; } if($email && !ValidateEmail($email)) { $error .= 'Please enter a valid e-mail address.<br />'; } // Check message (length) if(!$message || strlen($message) < 15) { $error .= "Please enter your message. It should have at least 15 characters.<br />"; } if(!$error) { $mail = mail(WEBMASTER_EMAIL, $subject, $message, "From: ".$name." <".$email.">\r\n" ."Reply-To: ".$email."\r\n" ."X-Mailer: PHP/" . phpversion()); if($mail) { echo 'OK'; } } else { echo '<div class="notification_error">'.$error.'</div>'; } } ?> hi every one i want to make a list from my database and if user click on one item it open a link... its a list of models of products so if click in one link me to the page of its full description, my database has the fields: "modelo" (model), and "paginal" the link page i make this code.. works fine cause display all the catalog but when i click in an item dont do nothing... hes the code.. what im missing?? tnx in advance <?PHP // Connect to MySQL Server @mysql_connect('localhost','user','password') or DIE("Couldn't Connect to MySQL Database"); // Select Database @mysql_select_db('zerocctv_almacen') or DIE("Couldn't Select Database"); $sql = "SELECT modelo, paginal,precio,foto FROM modelos"; $result=mysql_query($sql); $row_array=mysql_fetch_row($result); $string='<select name=selection><option value=>modelo</option>'; for ($i=0;$i < mysql_num_rows($result);$i++) { if ($row_array[0]=="") { $row_array=mysql_fetch_row($result); } else { $string .='<option value="'.$row_array[1].'">'.$row_array[0]."</option>"; $row_array=mysql_fetch_row($result); } } $string .='</SELECT>'; //echo "</label>"; echo $string; ?> I have a mysql table with the structure of Code: [Select] ID Menu_Name Parent_ID 1 Finance NULL 2 Business NULL 3 Investment 1 4 Trading 2 How can I create a html <ul><li> list based on the parent? i have made a simple header page for a project.
now i want to create a dropdown menu for a single menu item in the menu bar.
how i will do that ..??
for ex-under COURSES MENU, THE SUBMENU ARE : DEGREE,DIPLOMA,HIGHSCHOOL.
I am very new new php (wrote my first PHP script 5 Days ago) and am trying to give myself a crash course but I have hit a pit-stop which is killing me a little! I hope that title makes sense.... Basically I created PHP script to take data from a database and display in, I then wrote some code to use a drop down menu to order that data. That all worked ok until I tried to utilise some pagination. I can make the pagination work, and I can make the ordering work, but not at the same time! At the moment the code that I have will allow me to order the list and almost paginate it. There are 40 results and I want to display 10 at a time. When not using the ordering code I can paginate it perfectly but when I try to intergrate the two bits of code it will only display the first 10 results and not give me an option to go to the next page to see the rest! The code: if (!isset($_GET['start'])) { $_GET['start'] = 0; } $per_page = 10; $start = $_GET['start']; if (!$start) $start = 0; $sort = @$_POST['order']; if (!empty($sort)) { $get = mysql_query("SELECT bookname, bookauthor, bookpub, bookisbn FROM booktable ORDER BY ".mysql_real_escape_string($_POST['order'])." ASC LIMIT $start, $per_page"); } else { $get = mysql_query("SELECT bookname, bookauthor, bookpub, bookisbn FROM booktable ORDER BY bookname ASC LIMIT $start, $per_page"); } $record_count = mysql_num_rows($get); ?> <?php if (isset($_GET['showerror'])) $errorcode = $_GET['showerror']; else $errorcode = 0; ?> wont include all the html rubbish and the ordering menu! <div id="mid"> <?php echo "<table>"; echo "<tr>"; echo "<th>"; echo "</th>"; echo "<th>"; echo "Book Title"; echo "</th>"; echo "<th>"; echo "Book Author"; echo "</th>"; echo "<th>"; echo "Book Publisher"; echo "</th>"; echo "<th>"; echo "Book ISBN"; echo "</th>"; echo "<th>"; echo "</th>"; echo "</tr>"; while ($row = mysql_fetch_assoc($get)) { // get data $bookname = $row['bookname']; $bookauthor = $row['bookauthor']; $bookpub = $row['bookpub']; $bookisbn = $row['bookisbn']; echo "<tr>"; echo "<td>"; echo "<a href='addtolist.php?bookname=".$bookname."&bookauthor=".$bookauthor."&bookpub=".$bookpub."&bookisbn=".$bookisbn."'>Add to basket</a>"; echo "</td>"; echo "<td>"; echo $bookname; echo "</td>"; echo "<td>"; echo $bookauthor; echo "</td>"; echo "<td>"; echo $bookpub; echo "</td>"; echo "<td>"; echo $bookisbn; echo "</td>"; echo "</tr>"; } echo "</table>"; $prev = $start - $per_page; $next = $start + $per_page; if (!($start<=0)) echo "<a href='products.php?start=$prev'>Prev</a> "; //set variable for first page number $i=1; //show page numbers for ($x = 0; $x < $record_count; $x = $x + $per_page) { if ($start != $x) echo "<a class='pagin' href='products.php?start=$x'> $i </a>"; else echo "<a class='pagin' href='products.php?start=$x'><b> $i </b></a>"; $i++; } //show next button if (!($start >= $record_count - $per_page)) echo "<a class='pagin' href='products.php?start=$next'> Next </a>"; ?> Thank you so much for reading! |