-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
Have you tried using a root-relative link? For example, you could try something like: $day_post = "{$_SERVER['DOCUMENT_ROOT']}/includes/days"; Of course, you may need to adapt the path which comes after the SERVER variable. More information about the SERVER variable can be found here: http://php.net/manual/en/reserved.variables.server.php
-
Do you get any errors? If so, it helps to post the exact errors. When I paste your code into Dreamweaver's code view, a syntax error appears here: if ($ERROR) { } else { echo"database look up" include( 'database.php' ); Note the missing semicolon after the echo statement.
-
This $HTTP_POST_$FILES should be $HTTP_POST_FILES Well, technically $HTTP_POST_FILES has been depreciated, you should review the following: http://php.net/manual/en/reserved.variables.files.php
-
Pick a random email address out of a maillist
cyberRobot replied to ionicle's topic in PHP Coding Help
No worries -
Pick a random email address out of a maillist
cyberRobot replied to ionicle's topic in PHP Coding Help
This is probably doing homework, but since someone has already provided a solution [and I was intregued]...I thought I would work up a solution. <?php //INITIALIZE ARRAYS $emails = array('1@yahoo.com', '2@yahoo.com', '3@yahoo.com', 'G1@gmail.com', 'G2@gmail.com', 'G3@gmail.com', 'another@somewebsite.com', 'yetmore@zd.com', 'yetmoremore@zd.com'); $newEmails = array(); $usedDomains = array(); $uniqueDomains = array(); //WHILE THERE ARE EMAILS AVAILABLE, PROCESS THE NEXT RANDOM ENTRY while(!empty($emails)) { //GET RANDOM EMAIL $randomEntryID = array_rand($emails); $randomEntry = $emails[$randomEntryID]; $currentDomain = substr(strrchr($randomEntry, '@'), 1); //UPDATE ARRAYS $newEmails[] = $randomEntry; $usedDomains[] = $currentDomain; unset($emails[$randomEntryID]); } //REMOVE DUPLICATE DOMAINS (ALSO GIVES THE INDEX WHERE THE DOMAIN WAS FIRST USED) $uniqueDomains = array_unique($usedDomains); $uniqueIDs = array_keys($uniqueDomains); //DISPLAY EMAILS OF INTEREST foreach($uniqueIDs as $currID) { print '<div>' . $newEmails[$currID] . '</div>'; } //SHOW WHAT THE ARRAYS CONTAIN print '<pre>' . print_r($newEmails, true) . '</pre>'; print '<pre>' . print_r($usedDomains, true) . '</pre>'; print '<pre>' . print_r($uniqueDomains, true) . '</pre>'; print '<pre>' . print_r($uniqueIDs, true) . '</pre>'; ?> -
Pick a random email address out of a maillist
cyberRobot replied to ionicle's topic in PHP Coding Help
You could try something like the following: Put the email addresses in an array Use array_rand() to get a random email Save the random email into a new list. Grab the domain with explode() and store it in another array used for testing Get another random email address with array_rand(). See if the domain of the newly chosen email is already in the array of picked domains with in_array() If the domain has already been chosen from, get the next email. If not, store email and domain and continue processing the emails until done. Of course, I may have missed a step or two, but this should hopefully get you started. -
Note that you still need to work on the if test for "the". As it stands, an error will be flagged if "the" appears anywhere in the name. Based on the error message, you only want to flag an error if the name starts with "the". To fix the issue, you could switch to a regular expression or maybe use substr(): http://us1.php.net/substr
-
Also, is there a reason the "companyname" field is being displayed in the middle of your if/elseif tests? I would wait until all the tests are done.
-
Sorry, I just noticed that jasonk isn't the OP. @jasonk - Please don't hijack someone else's thread. If you have a question, please start a new one. @aelouch - Sorry about any confusion.
-
@jasonk - When posting code, please surround it with tags. It makes the post and code easier to read.
-
Side note: PHP provides a function for validating email addresses: http://php.net/manual/en/filter.examples.validation.php
-
To pass the information to the .js file, you could try something like the following. PHP script <html> <head> <title>Text File Input Test</title> <script type="text/javascript"> var textFileInfo = "<?php echo file_get_contents('myTextFile.txt'); ?>"; </script> <script language="javaScript" type="text/javascript" src="myJSCode.js"></script> </head> <body> </body> </html> myJSCode.js alert(textFileInfo); myTextFile.txt hello world
-
How did you learn HTML and CSS? If you found the learning experience effective, perhaps there are similar opportunities available with PHP. For me, I learn best by tearing existing things (that work) apart. I learned PHP by taking on a full-time job which involves developing a website that was created with PHP. Of course, I should mentioned that it was easier to pick up PHP since my previous job involved maintaining a website built with Perl. It also helps that I've taken several programming-related classes like C++. If you learn well from books, you should look through the suggestions posted here: http://forums.phpfreaks.com/topic/2307-good-programming-and-web-design-books/
-
Side notes: You could use a case-insensitive match by adding an "i" after the pattern delimiter: elseif ( !preg_match ("/^[a-z\s]+$/i",$companyname)) { Also, your pattern is going to turn away some perfectly acceptable company names such as AT&T, Phillips 66, Wal-Mart, etc.
-
Try changing elseif if ( !preg_match ("/^[a-zA-Z\s]+$/",$companyname)) { To elseif ( !preg_match ("/^[a-zA-Z\s]+$/",$companyname)) {
-
Why does my unCheckRadios function recall other functions?
cyberRobot replied to Frank P's topic in Javascript Help
Off hand, I'm not sure why the form submits in one case and not the other. But to prevent the form from submitting, you could try modifying the onclick event to something like this: <td class="uncheck-cell"><button id="A1a-button" onclick="unCheckRadios('A1a'); return false;">De-check</button></td> -
See example 1 here: http://php.net/manual/en/function.include.php
-
You could also use $record = $result->fetch_assoc();
-
onUnload="" function does not seem to work
cyberRobot replied to justin7410's topic in Javascript Help
The function named isn't spelled right. It should be alert02()....with a "t" before "02".- 4 replies
-
- javascript
- event handler
-
(and 1 more)
Tagged with:
-
In your actual code, is the following line commented out? // $headers .= 'To: '.$row['nickname'].' <'.$row['email'].'>'."\r\n"; The first argument for the mail() function is where the TO address should go. You currently have $row['email'] there: mail($row['email'], $sub, $email_cont, $headers);
- 6 replies
-
- email headers
- to: header
-
(and 1 more)
Tagged with:
-
Or you could just apply the styles to body. The <div> will inherit the styles automatically. @toolman - If you still need assistance, could you provide a little more information on what you're trying to accomplish?
-
Just keep in mind that this could open your script up to email injection attacks: https://www.google.com/search?q=php+email+injection+attack Information from the user, such is what you get from forms, should not be trusted. If you're not doing so already, the email address should be validated using something like the following: http://php.net/manual/en/filter.examples.validation.php Personally, I prefer to use a standard email as the from address such as the webmaster email for the website. It helps distinguish that the information came from an online form. Plus, it's easier to set up rules in an email client for filtering incoming mail.
-
What does your code that generates the email look like?
- 6 replies
-
- email headers
- to: header
-
(and 1 more)
Tagged with:
-
To be honest, I was thinking your comment was spam. Perhaps my sensors are set too high. Based on the code posted, the email address which comes from the user ($_POST['Email']) is only used in the message body. The problem is caused by the hard-coded value used for $EmailFrom. The headers argument for "From:" requires an email address. Since one wasn't provided, it uses an address defined by the server.