
ChaosKnight
Members-
Posts
183 -
Joined
-
Last visited
Never
Everything posted by ChaosKnight
-
In my database there are 2 tables, hotels and game_parks. At the bookings form, I use ajax to dynamically populate the dropdowns (country, province, city and accommodation). At first it only worked with the hotels, but now I want to add the parks into the same dropdown, sould I just make a second sql query and throw that into a while after the while of the hotels? Or is it possible to run the second query and then join the two arrays? Thanks
-
Brilliant! Thanks for the quick reply mate! SOLVED
-
Okay, so I am busy with a page that lists results neatly under each other in their own div, but some of the descriptions that I want to list in the div's are too long to fit inside, and I don't want to display a description that has about 250 words on a listing page... How can I cut the string in about 100 characters and then add an ellipse (...) at the end? I guess that will be the most logical way to deal with this problem, because the visitor can just click on 'view' and read the rest of the description... Thanks!
-
Thanks! Problem SOLVED!
-
Thanks, but I got it working with PHPMailer, so I decided to continue using it for now... Solved...
-
Here is the PHP code that is above the contact form, which runs when the submit button is pressed: <?php if (isset($_POST['submit'])){ require_once "PHPMailer/class.phpmailer.php"; // Database works fine, so I left out that code... if(mysql_query($sql,$link)){ $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = 'mail.domain'; $mail->SMTPAuth = true; $mail->Username = 'username'; $mail->Password = 'password'; $mail->From = 'from address'; $mail->SMTPDebug = true; $mail->AddReplyTo($email, $name); $mail->FromName = 'from <address>'; $mail->AddAddress('to address', 'name'); $mail->Subject = $subject; $mail->MsgHTML($message); $mail->AltBody=$message; if(!$mail->Send()){ echo "<h3>The message was not sent...</h3>"; }else{ echo "<h3>The message was sent successfully...</h3>"; } } mysql_close($db_link); } ?> When the above code is executed, the email is delivered successfully, but server responses are posted directly above the form, and this is not the desired result seeing that this is a contact form for people who visit the site. Here is some of the "server responses" that are displayed: SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "220, etc... And it ends with: 250 Message queued SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "221 Goodbye " SMTP -> get_lines(): $data is "221 Goodbye " SMTP -> FROM SERVER: 221 Goodbye I tried to find this lines in the page source that is recieved in the browser, but I can't find it, so it's not just some HTML, so I figured that it's server responses... But why is it showing above the form each time an email is submitted? Any ideas?
-
Okay, so I finally got PHPMailer to work, but now whenever I send an email, a whole bunch of server responses are echoed to the page. How can I hide this server responses? Thanks
-
It threw out the following error messages: Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in f:\wwwroot\domain\PHPMailer\class.phpmailer.php on line 53 Fatal error: Cannot instantiate non-existent class: phpmailer in f:\wwwroot\domain\contact.php on line 20 Line 20 in my code is: $mail = new PHPMailer(); So the problem is in the PHPMailer source code? I'm using PHPMailer v5.1 Here is PHPMailer v5.1 line 53: x[$h2].$hex[$h1]; } if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay $newline = ''; // check if newline first character will be point or not if ( $dec == 46 ) { $c = '=2E'; } } $newline .= $c; } // end of for $output .= $newline.$eol; } // end of while return $output; } Any ideas?
-
Okay, so I discovered this part of the forum just now. I never used a library script before, but I decided to use the PEAR Mail package for the emails that are sent from my site. I tried running this code: if (isset($_POST['submit'])){ require_once "mail/Mail.php"; // Database works fine, so db code left out... if(mysql_query($sql,$db_link)){ $from = "From <address>"; $to = "To <address>"; $host = "mail domain"; $username = "username"; $password = "password"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp =& Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $message); if (PEAR::isError($mail)) { echo "<h3>The message was not sent...</h3>" . $mail->getMessage(); }else{ echo "<h3>The message was sent successfully...</h3>"; } } mysql_close($db_link); } ?> But then the script generates this error messages: Warning: main(PEAR.php) [function.main]: failed to create stream: No such file or directory in f:\wwwroot\<address>\mail\Mail.php on line 46 Fatal error: main() [function.main]: Failed opening required 'PEAR.php' (include_path='.;c:\php4\pear') in f:\wwwroot\<address>\mail\Mail.php on line 46 What does this mean? Is it only because pear and mail is in different folders and I didn't include the PEAR.php in the contact page? PEAR.php is at: \domain\pear\PEAR\ Mail.php is at: \domain\mail\ Or is there some kind of other configuration that I missed? I only uploaded Mail and PEAR base files via ftp, did nothing extra Thanks
-
This code is supposed to display a form and when the submit button is pressed, include the PEAR Mail package and send an e-mail based upon the results sent back from the form. <?php if (isset($_POST['submit'])){ ini_set( "include_path", ( "public_html/domain/route/pear/PEAR/" . PATH_SEPERATOR . ini_get("include_path") ) ) ); include("db.php"); require_once "mail/Mail.php"; // DB code that works left out... if(mysql_query($sql,$link)){ //PEAR Mailer (Where the problem starts) $from = "From <address>"; $to = "To <address>"; $host = "url"; $username = "username"; $password = "password"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $message); if (PEAR::isError($mail)) { echo "<h3>The message was not sent...</h3>" . $mail->getMessage(); }else{ echo "<h3>The message was sent successfully...</h3>"; } } mysql_close($db_link) } ?> // Form left out because the code is correct When I go to the page, the include isn't displayed, it shows a blank where the form is supposed to be... So I don't even know if the e-mail will send correctly, because I can't submit anything. But when I comment out the include_path, mail functions and the require once, the form displays again, so I think the problem is there somewhere... I uploaded the PEAR Base files to the directory that I used in the include_path function, the pear mail package is also uploaded... I don't know if there are any extra configuration steps that I missed, because this is the very first time that I tried using a PEAR package... I just uploaded everything I thought was necessary. Thanks
-
Thanks for the posts, that was exactly what I wanted! Thanks once again
-
Hi, I have to make a database for a car rental company and their car groups work with letters of the alphabet, what I wanted to do was to create one table for the country in which the available car groups are listed as something like: ABCDEFGJKMNP, but I want to display information about the different car groups, so I thought it would work if I created another table where each row represents a car group. But then I realized the only way to make such a query would be to turn the string into an array and to query data based on each individual letter as elements of the array... How can I convert a string such as: ABCDEFGJKMNP into an array? Or does anyone perhaps have a better solution? Thanks
-
Okay so I used the file_exists function, and it returned that it found the file, then I commented out the $mail = new PHPMailer(); command and left the required, and it still executed the code after the require command. But when I uncommented the $mail = new PHPMailer(); command, the code stopped executing again... Any ideas on what could be wrong? Any help will be greatly appreciated... It seems as if the problem is in the object...
-
I'll quickly try those, but I discovered that even a simple script like the one below, stops executing completely... Is there some way to make sure that the PHP script "sees" class.phpmailer.php? I placed it in the same directory as the contact.php page though... And the webhost told me that the port is set to the default <?php require("class.phpmailer.php"); $mail = new PHPMailer(); echo "Hello World"; ?>
-
Hi, I'm busy implementing PHPMailer in a project, but after hours of hard work, I finally gave up... I got a sample script on one of the php threads here on phpfreaks, but when I try to send the e-mail from the script, the entire contact form include just turns blank, and none of the code gets executed... In the contact include at the top I have the code that gets executed when the sebmit button is pressed, and at the bottom is the HTML form, so I made the form action a blank (action="", I don't know if this is where the phpmailer experiences a problem?). But all the php code is executed, the only problem is the phpmailer code... require("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "$domainname"; $mail->SMTPAuth = true; $mail->Username = "$username"; $mail->Password = "$password"; $mail->From = "$from"; $mail->FromName = "$fromname"; $mail->AddAddress($to); $mail->AddReplyTo($reply); $mail->WordWrap = 50; $mail->IsHTML(true); $mail->Subject = "$subject"; $mail->Body = "$body"; if(!$mail->Send()) { echo "<h3>The message could not be sent...</h3>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; }else{ echo "<h3>The message was sent successfully...</h3>"; } Not even the error info is return, it just return a complete blank... Any thoughts??
-
I decided to include PHPMailer for use with the outgoing e-mails, but for some reason when I submit the form, the page include just disappears and no mail gets sent... Here is the code that I tried: require("class.phpmailer.php"); $mailer = new PHPMailer(); $mailer->IsSMTP(); $mailer->Host = $host; $mailer->SMTPAuth = true; $mailer->Username = $user; $mailer->Password = $password; $mailer->From = $address_from; $mailer->AddAddress($address_to); $mailer->WordWrap = 50; $mailer->IsHTML(true); $mailer->Subject = $subject; $mailer->Body = $message; if($mailer->Send()){ echo "<h3>The message was sent successfully...</h3>"; }else{ echo "<h3>The message could not be sent...</h3>" . $mailer->ErrorInfo; exit; } Everythng is on the same page as the form, and the other code works fine, it's only the e-mail part... Any help will be greatly appreciated Thanks
-
I solved it, I only missed a clear: left
-
Why doesn't this background image show up in Firefox and Google Chrome, but it does in Internet Explorer and Opera?: #nav { margin: 0px; padding: 0px; border: 0px; height: 35px; width: 780px; background-image: url(images/navbar_bg.png); background-repeat: no-repeat; } Any ideas?
-
Also, you shouldn't use filenames like that in the URL, rather use a switch statement and use related references such as: content=home, instead of content=home.html. It's never a good idea to send too much info about how the files are structured and make it visible for everyone to see...
-
Try this: <?php if(isset($_GET['content'])){ $content = $_GET['content']; } include($content); ?>
-
$date = date("Y-m-d H:i:s", time());
-
Thank you, this is exactly what I wanted Thanks a lot mate
-
Is it possible to access a mail server (at a shared hosting company), retrieve the e-mails, and then store it in a database table? This is something that I always wanted to know, and I'm very eager to implement this in a website. I know that it's possible with IMAP, but the hosting company that the website that I'm busy with, only supports POP3. I would also appreciate it if anyone can tell me where I can find an in depth tutorial for this... Thanks!
-
So is this secure enough to go to the database?: $message = mysql_real_escape_string($_POST['message']);
-
Hi, I have a form that posts data to the database, so I'm very concerned about the security... My question is if this will work?: foreach ($_POST as $field => $value){ $$field = mysql_real_escape_string(strip_tags(trim($value))); } Any help will be greatly appreciated