j5uh
Members-
Posts
58 -
Joined
-
Last visited
Never
Everything posted by j5uh
-
Ok so this is what I need the script to do... an email is sent with data in the body to a certain email every day at a certain time. When that email is sent it should pipe it to the script and the script should auto pull the emails from a db I made using mysql and forward that email on to the list. I'm still a noobie in php so thanks for baring with me.
-
so I've figured out the From and Subject not showing up issue but the email message is not going through ... ??? this is what i have. #!/usr/bin/php -q <?php ini_set('error_reporting',E_ALL); $db_host = "asd"; $db_user = "asd"; $db_pwd = "asd"; $db_name = "asd"; $db_table = "users"; $db_emailfield = "email"; mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); $sql = "SELECT `$db_emailfield` FROM `$db_table`;"; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)){ $emails = $row['email']; $ChangeTo = 'noreply@asd.com'; $ForwardTo = $emails; // Read the pipe $open_file = fopen("php://stdin","r"); $email = ""; while (!feof($open_file)) { $email .= fread($open_file,1024); } fclose ($open_file); // Take info from emai; $lines = explode("\n",$email); $from = "noreply@123.com"; $subject = "123"; $message = ""; $to = $ForwardTo; $splittingheaders = true; for ($i=0;$i<count($lines);$i++) { if ($splittingheaders) { if (preg_match("/^From: (.*)/",$lines[$i],$matches)) { if (strpos($lines[$i],"<")) { // The name is before the email $data = explode ("<",$lines[$i]); $from = substr(trim($data[1]),0,-1); } else { $from = $matches[1]; } } if (preg_match("/^Subject: (.*)/",$lines[$i],$matches)) { $subject = $matches[1]; } } else { $message .= $lines[$i]."\n"; } if (trim($lines[$i]=="")) { $splittingheaders = false; } } $message = <<< EOF $message EOF; $headers = "Content-type: text/html\n"; $headers .= "From: $from\n"; $headers .= "Return-Path: $from\n"; //$headers .= "To: $to\n"; mail ($ForwardTo,$subject,$message,$headers); } ?>
-
rubing, all I'm doing is sending text in the email. nothing else... =/ I have no experience with PEAR though.
-
I know the script is working but when I recieve the emails, I see no content or a From... what could be wrong?
-
ok it's working now. had the email piping mixed up. my only concern is the emails are being sent but they go to junk and they send 2 copies of the same email. ???
-
ok... the script runs when i view it through my browser but no luck when i pipe the email to it.... I'm using /home/newhost/public_html/asd/ss/mailer.php any ideas?
-
ok here is what i used to pull the email addresses from a db... hope this will help someone else in the future.
-
this is what i used and it's working!!!
-
i think it's working now !!!! =) let me check and report back to you...
-
jonsjava, it's still giving me an error on this line while($row = mysql_fetch_assoc($result)){ I'm forever thankful for all your help...
-
jonsjava, This is what I have Still giving me that line 11 error... =/
-
jonsjava, I've ran that code but it's giving an error at Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/newhost/public_html/asd/ss/mailer.php on line 11 Which is the code while($row = mysql_fetch_array($result)){ I'm having trouble with that line of code. I can't seem to figure it out.
-
how can i modify that code to pull the email addresses to forward to from a mysql db?
-
I've found this new script from here It's exactly what I need but I need it to pull the list of emails from a DB... how can I modify this to that?
-
ok here is what i have now... #!/usr/bin/php -q <?php ini_set('error_reporting',E_ALL); include("config.php"); mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); $sql = "SELECT $db_emailfield FROM $db_table"; $result = mysql_query($sql); $email_file = fopen("php://stdin", "r"); while($row = mysql_fetch_array($result)){ $email = $row['email']; $message = $email_file; $mailhead = 'MIME-Version: 1.0' . "\n"; $mailhead .= 'Content-type: text/html; charset=UTF-8' . "\n"; $mailhead .= "From: $fromname\n"; if(mail ($email, $emailsubject, $message, "From: $fromname <$fromemail>", $mailhead)) echo "Messages sent"; } ?> The piping is correct ... I have /home/newhost/public_html/asd/ss/emailer.php When I access the script directly, it's giving me a an error below Warning: mail() expects parameter 3 to be string, resource given in /home/newhost/public_html/asd/ss/emailer.php on line 23
-
ok sweet! i've switched providers to hostgator and i have cpanel running. Does anyone have a script by any chance that can forward the email address to the correct mail list from a db? Here is the script I'm using so far and it's not working... <?php include("config.php"); mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); $sql = "SELECT $db_emailfield FROM $db_table"; $result = mysql_query($sql); $email_file = fopen("php://stdin", "r"); while($row = mysql_fetch_array($result)){ $email = $row['email']; $message = $email_file; $mailhead = 'MIME-Version: 1.0' . "\n"; $mailhead .= 'Content-type: text/html; charset=UTF-8' . "\n"; $mailhead .= "From: $fromname\n"; if(mail ($email, $emailsubject, $message, "From: $fromname <$fromemail>", $mailhead)) echo "Messages sent"; } ?>
-
ok with cpanel, i'm guessing you just use the pipe method to pipe the email into a script. interesting.
-
could you explain the cPanel way too? I guess I could use one of my other hosting companies to see how it would work... but if I can get it working on godaddy, it would be ideal.
-
I'm actually using godaddy hosting. Do you have a script in mind that I can use? not sure how i can tie in an address with a script.
-
Please help! ??? I'm in need of a software or php script that can forward an email to a list that is on a mysql db. So an email will be sent to a specific email address and that should trigger the software or script to run through the email addresses in the db and forward that to everyone. Any ideas?
-
How do you provide a unique url that expires or prevent a user from accessing...
j5uh replied to j5uh's topic in MySQL Help
ok user authentication is good but anyone know of a script that has an admin cpanel which every user registered has to have it approved before they can access the members page? -
How do you provide a unique url that expires or prevent a user from accessing your registration page directly? I have a registration page that automatically lets you access the members page without ever being approved. This Reg form should only be accessible after you pay a paypal fee. But I think people are finding this link through search engines. What's the best way to stop this? .htaccess? or is there a way that the page won't load unless it's coming from paypal page? please, any advice is welcome.
-
I have a script here that I am using to extract the data from a .csv file to upload to a mysql db. It work's really well but I only want it to update whenever it has a new file or new data. So basically I wouldn't mind if the script ran and attempt to update, but if all fields match I want it to cancel the update. Here is my code: <? /********************************************************************************************/ /* Code at http://legend.ws/blog/tips-tricks/csv-php-mysql-import/ /* Edit the entries below to reflect the appropriate values /********************************************************************************************/ $databasehost = "xx"; $databasename = "xx"; $databasetable = "xx"; $databaseusername ="xx"; $databasepassword = "xx"; $fieldseparator = ";"; $lineseparator = "\n"; $csvfile = "file.csv"; /********************************************************************************************/ /* Would you like to add an ampty field at the beginning of these records? /* This is useful if you have a table with the first field being an auto_increment integer /* and the csv file does not have such as empty field before the records. /* Set 1 for yes and 0 for no. ATTENTION: don't set to 1 if you are not sure. /* This can dump data in the wrong fields if this extra field does not exist in the table /********************************************************************************************/ $addauto = 1; /********************************************************************************************/ /* Would you like to save the mysql queries in a file? If yes set $save to 1. /* Permission on the file should be set to 777. Either upload a sample file through ftp and /* change the permissions, or execute at the prompt: touch output.sql && chmod 777 output.sql /********************************************************************************************/ $save = 0; $outputfile = "output.sql"; /********************************************************************************************/ if(!file_exists($csvfile)) { echo "File not found. Make sure you specified the correct path.\n"; exit; } $file = fopen($csvfile,"r"); if(!$file) { echo "Error opening data file.\n"; exit; } $size = filesize($csvfile); if(!$size) { echo "File is empty.\n"; exit; } $csvcontent = fread($file,$size); fclose($file); $con = @mysql_connect($databasehost,$databaseusername,$databasepassword) or die(mysql_error()); @mysql_select_db($databasename) or die(mysql_error()); $lines = 0; $queries = ""; $linearray = array(); foreach(split($lineseparator,$csvcontent) as $line) { $lines++; $line = trim($line," \t"); $line = str_replace("\r","",$line); /************************************************************************************************************ This line escapes the special character. remove it if entries are already escaped in the csv file ************************************************************************************************************/ $line = str_replace("'","\'",$line); /***********************************************************************************************************/ $linearray = explode($fieldseparator,$line); $linemysql = implode("','",$linearray); if($addauto) $query = "insert into $databasetable values('month','$linemysql');"; else $query = "insert into $databasetable values('$linemysql');"; $queries .= $query . "\n"; @mysql_query($query); } @mysql_close($con); if($save) { if(!is_writable($outputfile)) { echo "File is not writable, check permissions.\n"; } else { $file2 = fopen($outputfile,"w"); if(!$file2) { echo "Error writing to the output file.\n"; } else { fwrite($file2,$queries); fclose($file2); } } } echo "Found a total of $lines records in this csv file.\n"; ?>
-
thank you so much that worked like a charm. ;D ;D
-
I have a form that i'm working with and once you hit register it shows 2 footers. How can I fix this? Here is what i have: <?php // Connects to your Database mysql_connect("xx", "xx", "xx") or die(mysql_error()); mysql_select_db("xx") or die(mysql_error()); //This code runs if the form has been submitted if (isset($_POST['submit'])) { //This makes sure they did not leave any fields blank if (!$_POST['firstname'] | !$_POST['lastname'] | !$_POST['address'] | !$_POST['city'] | !$_POST['state'] | !$_POST['zipcode'] | !$_POST['email'] ) { die('You did not complete all of the required fields'); } // checks if the email is in use if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $usercheck = $_POST['email']; $check = mysql_query("SELECT email FROM xx WHERE email = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { die('Sorry, the E-mail '.$_POST['email'].' is already in use.'); } // now we insert it into the database $insert = "INSERT INTO xx (firstname, lastname, address, city, state, zipcode, country, phone, email) VALUES ('".$_POST['firstname']."', '".$_POST['lastname']."', '".$_POST['address']."', '".$_POST['city']."', '".$_POST['state']."', '".$_POST['zipcode']."', '".$_POST['country']."', '".$_POST['phone']."', '".$_POST['email']."')"; $add_member = mysql_query($insert); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="includes/main.css" /> <link rel="stylesheet" type="text/css" href="includes/typography.css" /> </head> <body> <!-- Begin Wrapper --> <div id="wrapper"> <!-- Begin Logo --> <?php include("header.php"); ?> <!-- End Header --> <!-- Begin Navigation --> <div id="navigation"> <div align="center"> <?php include("nav.php"); ?> </div> </div> <!-- End Navigation --> <!-- Begin Left Column --> <!-- Begin background --> <div id="background"> <div id="leftcolumn"> Left Column </div> <!-- End Left Column --> <!-- Begin Right Column --> <div id="rightcolumn"> <h3>Attendee Registration </h3> <p> Thank you for your registration. Your registration will be processed in the next 24 hours. See you soon in Las Vegas.</p> <br /><br /><br /><br /><br /><br /><br /><br> </div> <!-- End Right Column --> </div> <!-- End background --> <!-- Begin Footer --> <div id="footer"> <?php include("footer.php"); ?></div> <!-- End Footer --> </div> <!-- End Wrapper --> </body> </html> <?php } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="includes/main.css" /> <link rel="stylesheet" type="text/css" href="includes/typography.css" /> </head> <body> <!-- Begin Wrapper --> <div id="wrapper"> <!-- Begin Logo --> <?php include("header.php"); ?> <!-- End Header --> <!-- Begin Navigation --> <div id="navigation"> <div align="center"> <?php include("nav.php"); ?> </div> </div> <!-- End Navigation --> <!-- Begin Left Column --> <!-- Begin background --> <div id="background"> <div id="leftcolumn"> Left Column </div> <!-- End Left Column --> <!-- Begin Right Column --> <div id="rightcolumn"> <h3>Attendee Registration <br /> </h3> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0"> <tr><td>First Name:</td><td> <input type="text" name="firstname" maxlength="60"> </td></tr> <tr><td>Last Name:</td><td> <input type="text" name="lastname" maxlength="60"> </td></tr> <tr><td>Address:</td><td> <input type="text" name="address" maxlength="60"> </td></tr> <tr><td>City:</td><td> <input type="text" name="city" maxlength="60"> </td></tr> <tr><td>State:</td><td> <input type="text" name="state" maxlength="60"> </td></tr> <tr><td>ZIP Code:</td><td> <input type="text" name="zipcode" maxlength="20"> </td></tr> <tr><td>Country:</td><td> <input type="text" name="country" maxlength="60"> </td></tr> <tr><td>Phone:</td><td> <input type="text" name="phone" maxlength="60"> </td></tr> <tr><td>E-mail:</td><td> <input type="text" name="email" maxlength="60"> </td></tr> <tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> </table> </form> <?php } ?> </div> <!-- End Right Column --> </div> <!-- End background --> </div> <!-- End Wrapper --> </body> </html>