phpretard
-
Posts
821 -
Joined
-
Last visited
Never
Posts posted by phpretard
-
-
Or I guess the question is can I form that array with sessions?
$arrEmails=array(false,false,false,false,false);
-
That is good stuff, I am not really sure where to put it though.
I should have posted the way the email inputs are "built":
<?php if (!isset($_POST['AddEmailBoxes'])) {$_SESSION['Totalboxes']="5";} elseif (isset($_POST['AddEmailBoxes'])){$_SESSION['Totalboxes']=$_POST['AddEmail'] + 1;} if (isset($_POST['DeleteEmailBoxes'])) {$_SESSION['Totalboxes']=$_POST['AddEmail'] - 1;} $TotalBoxes=$_SESSION['Totalboxes']; for ($i=1; $i < $TotalBoxes; $i++) { $EmailText=" <input style=\"width:200px;\" type=\"text\" name=\"InviteEmail[]\" value=\"\"> Email $i "; echo $EmailText; } ?>
Does this make a difference?
-
I am trying to validate multiple emails on one submit.
The rules are
1. to validate at least the format
2. Then at least 5 email must be submitted
3. If there is an error the input with the error should be indicated. Also not deleting any emails that were correct.
I know many ways to display the errors I don't exactly what to do with the array values in terms of validating and re-inserting them into the appropriate input boxes.
if (isset($_POST['submit'])){ $Emails=$_POST['InviteEmail']; //I know there will probably need to be a "foreach" in here somewhere. if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $Emails)) { $error="X number of emails are incorrect"; } } //END POST <form action="" method="post"> <input style="width:200px;" type="text" name="InviteEmail[]" value=""> Email 1 <input style="width:200px;" type="text" name="InviteEmail[]" value=""> Email 2 <input style="width:200px;" type="text" name="InviteEmail[]" value=""> Email 3 <input style="width:200px;" type="text" name="InviteEmail[]" value=""> Email 4 <input style="width:200px;" type="text" name="InviteEmail[]" value=""> Email 5 <input style="width:200px;" type="text" name="InviteEmail[]" value=""> Email 6 <br /> <input type="submit" name="submit" value="Send Emails"> </form>
Any pointers would be appriciated. Thanks
-
Thank you! That was painful.
-
Why does that work because of a freekin dot????
-
I am trying to combine 2 words from a row called key. The row key has 20 entries and all are different words.
For example one word in row key is "Green"
Anthoer is "Spoon".
On a random basis I would like to echo "GreenSpoon" // or any other combination of words
The code below only works on one page by itself.
I need to include it in another page and when I do it only echos 1 word.
<? include ("../db.php"); $EmailKey=mysql_query("SELECT * FROM emailkeys ORDER BY RAND() limit 2"); if (!$EmailKey){die(mysql_error());} WHILE ($row=mysql_fetch_array($EmailKey)){ $key1=$row['key']; echo $key1; } mysql_close($con); ?>
Thank you!
-
Thanks a million!
I chose not to use the array but it worked both ways.
-
I got this up to:
min 8
max 20
must be numbers and letter
I need at least one Uppercase letter and can't figure it out...
function validate_password($password, $min_char = 8, $max_char = 20) { $password = trim($password); $eregi = eregi_replace('([a-zA-Z0-9_]{'.$min_char.','.$max_char.'})', '', $password); if(empty($eregi)) { return true; } else { return false; } }
Thank you for your help!
-
Like this?
<?php echo Phone($Phone); ?> <?php echo Phone($AltPhone); ?> <?php echo Phone($Fax); ?>
-
I am validating phone numbers. I have to validate 3.
Do I need to copy this function 3 times or is there an easier way with less code?
$Phone="1234567890";
$AltPhone="0987654321";
$Fax="6543219870";
It works great for one!
function Phone($Phone) { $stripped= preg_replace("/[^0-9]/", "", $Phone); if(strlen($stripped) == 7) return preg_replace("/([0-9]{3})([0-9]{4})/", "$1-$2",$stripped); elseif(strlen($stripped) == 10) return preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "($1) $2-$3",$stripped); else return $Phone; }
Thank you!
-
-
Is this a tough question? I thought it would be easy (for someone)...
-
How can I Get "www.dontmatter.com" out of the array and into a variable.
Array ( [scheme] => https [host] => www.dontmatter.com [path] => /index.php [query] => limitstart=3 ) /index.php
-
I am trying to simulate a default 404 for all sites on my server.
I need to parse the referring page and redirect to the home page of the applicable site.
Here's what I have so far...
<?php $url=$_SERVER['HTTP_REFERER']; //$url = 'https://www.dontmatter.com/index.php?limitstart=3 '; // this was for testing print_r(parse_url($url)); echo parse_url($url, PHP_URL_PATH); $404F=$???; // I am trying to get the [host] value from this array and put it in a var. header( "Location: $404F" ) ; ?>
Thank you
PS. this is just a band aid until I figure out Plesk
-
I am trying to get a time select box
From: 8:00am
To: 5:00pm
I need both select boxes to go in order all the way around the clock
BUT
The From: select box should have 8:00am selected
The To: select box should have 5:00pm selected
<select> <? for ($i=1; $i < 12; $i++) { $Schedule="<option>$i:00am</option>"; echo $ScheduleAM; } ?> </select>
My brain hurts.
-
Thank you all!
-
I know how and javascript would do fine I supose.
Any pointers on the Cron?
Would I set a time() value in a DB?
-
Is there a time redirect I can code that will (in theory) set a cookie or session when a visitor hits my site and if they sit dormant too long will redirect them to another site (of mine)?
<?php $Intial=time(); $HowLong=???; $_SESSION['BeatIT']=$Intial; if ($_SESSION['BeatIT'] < "$HowLong"){ // redirect here } ?>
Any thoughts?
-
...and hope they don't "reply all"
-
Excellent Refferece...
If a user posts info@test.com how do I separate the "info@" from the "test.com" so it can be included in the example array?
<?php $EmailAddress="info@test.com"; // What is the best wat to seperate? // checkdnsrr() support for Windows by HM2K <php [spat] hm2k.org> function win_checkdnsrr($host, $type='MX') { if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { return; } if (empty($host)) { return; } $types=array('A', 'MX', 'NS', 'SOA', 'PTR', 'CNAME', 'AAAA', 'A6', 'SRV', 'NAPTR', 'TXT', 'ANY'); if (!in_array($type,$types)) { user_error("checkdnsrr() Type '$type' not supported", E_USER_WARNING); return; } @exec('nslookup -type='.$type.' '.escapeshellcmd($host), $output); foreach($output as $line){ if (preg_match('/^'.$host.'/',$line)) { return true; } } } // Define if (!function_exists('checkdnsrr')) { function checkdnsrr($host, $type='MX') { return win_checkdnsrr($host, $type); } } /* example */ $domains=array('example.com','php.net'); // This is direct input without the prefix. foreach ($domains as $domain) { $result=checkdnsrr($domain); echo $domain.':'; echo $result?"true\n":"false\n"; } ?>
-
Can anyone point me in the direction of how to validate an email address based on DNS not just character string?
Usinf PHP of course.
-
take away
error_reporting (E_ALL | E_NOTICE); error_reporting(E_ALL | E_STRICT);
-
Thanks!
-
I am currenty working on date issues so here is some script that spits out th date...
<? if (isset($_POST['date'])){ $month=$_POST['month']; $day=$_POST['day']; $year=$_POST['year']; echo "$month / $day / $year"; } $thisYear=date('Y'); $thisYearPlus=date('Y', strtotime('+1 year')); // ADD WHAT YOU WANT echo"<form action='' method='post'>"; echo"<select name=month>";getoption(1, 12, date("m"));echo "</select>"; echo"<select name=day>";getoption(1, 31, date("d"));echo "</select>"; echo"<select name=year>";getoption($thisYear, $thisYearPlus, date('Y'));echo "</select>"; echo"<input type='submit' name='date' value='GO'>"; echo"</form>"; function getoption($start, $end, $if) { for ($i=$start;$i<=$end;$i++) { echo "<option value=$i"; if ($i == $if) { echo " selected";} echo ">$i"; } } ?>
$helpful="Maybe";
Multiple Email Validation
in PHP Coding Help
Posted
The simple work behind the code:
1. There is a sesion set that determines the number of inputs
2. There are three submit button in the form
a. Submit 1 adds a number to the session thus adding an input
b. Submit 2 subtracts a number from the session thus removing an input
c. Submit 3 submits all the inputs
3. When the form is submitted the post value is however many emails were added to the form.
I am not sure what to do with them at this point.
My Biggest Questions I suppose is how do I capture email$i in a post? The $i variable could be any number of values. So $email1=$_POST['email1']; (how I usually do it) won't work becuase there is no set number.
Can I use the SESSSION to build the $email$i=$_POST['email$i']?
Step 1 and 2(a-c) works great but it may not be the best approach.
Please don't jet on me yet...