Grodo
-
Posts
74 -
Joined
-
Last visited
Never
Posts posted by Grodo
-
-
That is because you use 3 of the same varibles in your for loop
Use different varibles try that see if it works
-
Whats wrong with my preg_replace? It strips the numbers but it also strips the - (dash) from the string.
I wanted it to grab just the numbers
$db_fax = preg_replace("/[a-zA-Z]/xms","",$db_fax);
Thanx like always
Grodo
-
Try this
<?php if ((the_author_ID())= '4') echo 'boo'; else echo 'not boo'; ?>
or
Try this
<?php if (the_author_ID()= '4') echo 'boo'; else echo 'not boo'; ?>
or
Try this
<?php $author = the_author_ID(); if ($author = '4') echo 'boo'; else echo 'not boo'; ?>
-
Figured it out the problem was that there was 2 equals. $process==True; removed one and it works mdnghtblue thank you for leading me in the right direction (well kind of)
-
Hmmmmm still the same problem
-
Having trouble with my script seems like the if is bypassed staright into the else statement. I have no idea what is wrong. I think the problem is in the for loop not setting the $process to true. However nothing after the if statement works; seems like it just goes straight to the else. Just to make things clear im talking about if ($process==TRUE) statement.
Thanks Again
Grodo
// Ok lets validate some parameters! With error reporting! $error = 0; //We make an array to hold the error code information $errorcodes = array('ok', 'ok', 'ok', 'ok', 'ok', 'ok'); if ($db_name == "") { $errorcodes[0] = ename; $error = 1; } if ($db_snumber == "") { $errorcodes[1] = esnumber; $error = 1; } if ($db_city == "") { $errorcodes[2] = ecity; $error = 1; } if ($db_state == "") { $errorcodes[3] = estate; $error = 1; } if ($db_zip == "") { $errorcodes[4] = ezip; $error = 1; } if ($db_country == "") { $errorcodes[5] = ecountry; $error = 1; } // Code that gives the ok to process for ( $i = 0; $i<6; $i++ ) { if ( $errorcodes[$i] == "ok" && $error == "0" ) { $process == TRUE; } else { $process == FALSE; } } // This is the if statement that tells script to write if ($process==TRUE) { //Lets Try To Open Our All Data Campaign File $csv_alldata = "alldata.csv"; if (is_writable($csv_alldata)) { if (!$csv_alldatahandle = fopen($csv_alldata,"a")) { echo "<p>Cannot open file $csv_alldata</p>"; exit; } } // Alright! Its time to start writing // Writing All Data Name, Company, Email, Phone, And Fax $csv_itemalldata = "\"$db_name\",\"$db_company\",\"$db_email\",\"$db_phone\",\"$db_snumber\",\"$db_address2\",\"$db_city\",\"$db_state\",\"$db_country\",\"$db_zip\",\"$db_fax\"\n"; if (is_writable($csv_alldata)) { if (fwrite($csv_alldatahandle, $csv_itemalldata) === FALSE) { echo "Cannot write to file $csv_alldata"; exit; } } // Lets Close The File fclose($csv_alldatahandle); } else { // Lovely Error Codes :-) if ( $errorcodes[0] == "ename") {print "<font color =red><b><ul type=circle><li>State / Territory Field Missing<br></font></b></ul></li>";} if ( $errorcodes[1] == "esnumber") {print "<font color =red><b><ul type=circle><li>Street Number Missing<br></font></b></ul></li>";} if ( $errorcodes[2] == "ecity") {print "<font color =red><b><ul type=circle><li>City Field Missing<br></font></b></ul></li>";} if ( $errorcodes[3] == "estate") {print "<font color =red><b><ul type=circle><li>State Field Missing<br></font></b></ul></li>";} if ( $errorcodes[4] == "ezip" ) {print "<font color =red><b><ul type=circle><li>Postal Code Field Missing<br></font></b></ul></li>";} if ( $errorcodes[5] == "ecountry") {print "<font color =red><b><ul type=circle><li>Country Field Missing<br></font></b></ul></li>";} // SET Html code to a String $htmlcode = '<html>just some html code'; if ($error=="1") { print($htmlcode); print "<body bgcolor=#ffffcc>"; } }
-
MMMMM Thought I had it... the values were read but now the form keeps displaying its self i was going to create another page in an include if there was no errors. Orignally there was a blank page if everythign was sent without any errors. However now it just keeps showing the same page(newsform.html). I think that suspending of the php for a second made the browser think it was supposed just skip a section of the else. Here is my whole code I am really lost now :-x I have been working on this for a while now and I cant seem to figure it out
phpharvester.php
<?php // Information Harvester v 1.0 //Special thanks to the members of PHP Freaks.com that made this script possible ;-) // This PHP script collects information that was passed through a form. // Then in out puts the data into categories and creates different campaign .csv files // July 25, 2007 include ('functions.php'); // MMMMM Lets Get That Raw Data! if (isset($_POST["submit"])) { // Get data from post $db_name = $_POST["db_name"]; $db_company = $_POST["db_company"]; $db_email = $_POST["db_email"]; $db_fax = $_POST["db_fax"]; $db_phone = $_POST["db_phone"]; $db_snumber = $_POST["db_snumber"]; $db_address2 = $_POST["db_address2"]; $db_city = $_POST["db_city"]; $db_state = $_POST["db_state"]; $db_zip = $_POST["db_zip"]; $db_country = $_POST["db_country"]; // After Data Gathered Format It | Trim removes white space | Strip Tags removes html for security // Format Name $db_name = strip_tags($db_name); //Format Company $db_company = strip_tags($db_company); // Format Email $db_email = strip_tags($db_email); $db_email = trim($db_email); //Format Fax $db_fax = strip_tags($db_fax); $db_fax = preg_replace("/[a-zA-Z]/xms","",$db_fax); // Lets Extract All Numbers From The Fax Data $db_fax = trim($db_fax); //Format Phone $db_phone = strip_tags($db_phone); $db_phone = preg_replace("/[a-zA-Z]/xms","",$db_phone); // Lets Extract All Numbers From The Phone Data $db_phone = trim($db_phone); //Format Address $db_snumber = strip_tags($db_snumber); //Format Address2 $db_address2 = strip_tags($db_address2); //Format city $db_city = strip_tags($db_city); //Format State $db_state = strip_tags($db_state); //Format Postal Code $dp_zip = strip_tags($db_zip); //Format Country $dp_country = strip_tags($db_country); } // Ok lets validate some parameters! With error reporting! //First we make an array to hold the error code information $errorcodes = array('ok', 'ok', 'ok', 'ok', 'ok', 'ok'); if ($db_name == "") { $errorcodes[0] = ename; } if ($db_snumber == "") { $errorcodes[1] = esnumber; } if ($db_city == "") { $errorcodes[2] = ecity; } if ($db_state == "") { $errorcodes[3] = estate; } if ($db_zip == "") { $errorcodes[4] = ezip; } if ($db_country == "") { $errorcodes[5] = ecountry; } // Code that gives the ok to process for ( $i = 0; $i<6; $i++ ) { if ( $errorcodes[$i] == "ok" ) { $process == TRUE; } else { $process == FALSE; } } if (isset($db_name) && isset($db_snumber) && isset($db_city) && isset($db_state) && isset($db_zip) && isset($db_country) && $process == TRUE) { //Lets Try To Open Our Fax Campaign File $csv_fax = "fax.csv"; if (is_writable($csv_fax)) { if (!$csv_faxhandle = fopen($csv_fax,"a")) { echo "<p>Cannot open file $csv_fax</p>"; exit; } } //Lets Try To Open Our Telemarketing Campaign File $csv_phone = "phone.csv"; if (is_writable($csv_phone)) { if (!$csv_phonehandle = fopen($csv_phone,"a")) { echo "<p>Cannot open file $csv_phone</p>"; exit; } } //Lets Try To Open Our All Data Campaign File $csv_alldata = "alldata.csv"; if (is_writable($csv_alldata)) { if (!$csv_alldatahandle = fopen($csv_alldata,"a")) { echo "<p>Cannot open file $csv_alldata</p>"; exit; } } // Lets Try To Open Our Mailing List $csv_mail = "mail.csv"; if (is_writable($csv_mail)) { if (!$csv_mailhandle = fopen($csv_mail,"a")) { echo "<p>Cannot open file $csv_mail</p>"; exit; } } // Lets Try To Open Our Formated mailing list $txt_mail = "mailformat.txt"; if (is_writable($txt_mail)) { if (!$txt_mailhandle = fopen($txt_mail,"a")) { echo "<p>Cannot open file $txt_mail</p>"; exit; } } // Alright! Its time to start writing // Writing All Data Name, Company, Email, Phone, And Fax $csv_itemalldata = "\"$db_name\",\"$db_company\",\"$db_email\",\"$db_phone\",\"$db_snumber\",\"$db_address2\",\"$db_city\",\"$db_state\",\"$db_country\",\"$db_zip\",\"$db_fax\"\n"; if (is_writable($csv_alldata)) { if (fwrite($csv_alldatahandle, $csv_itemalldata) === FALSE) { echo "Cannot write to file $csv_alldata"; exit; } } // Lets Close The File fclose($csv_alldatahandle); // Writing Telemarket Campaign $csv_itemphonedata = "\"$db_name\",\"$db_company\",\"$db_email\",\"$db_phone\"\n"; if (is_writable($csv_phone)) { if (fwrite($csv_phonehandle, $csv_itemphonedata) === FALSE) { echo "Cannot write to file $csv_phone"; exit; } } // Lets Close The File fclose($csv_phonehandle); // Writing Fax Campaign $csv_itemfaxdata = "\"$db_fax\"\n"; if (is_writable($csv_fax)) { if (fwrite($csv_faxhandle, $csv_itemfaxdata) === FALSE) { echo "Cannot write to file $csv_fax"; exit; } } // Lets Close The File fclose($csv_faxhandle); // Writing Mail List Campaign $csv_itemmaildata = "\"$db_name\",\"$db_company\",\"$db_email\",\"$db_phone\",\"$db_snumber\",\"$db_address2\",\"$db_city\",\"$db_state\",\"$db_country\",\"$db_zip\"\n"; if (is_writable($csv_mail)) { if (fwrite($csv_mailhandle, $csv_itemmaildata) === FALSE) { echo "Cannot write to file $csv_mail"; exit; } } //Close File fclose($csv_mailhandle); // Writing Format Mail $txt_data = "$db_name\n$db_company\n$db_snumber\n$db_address2\n$db_city\n$db_state\n$db_zip\n$db_country\n\n"; if (is_writable($txt_mail)) { if (fwrite($txt_mailhandle, $txt_data) === FALSE) { echo "Cannot write to file $txt_mail"; exit; } } fclose($txt_mailhandle); } else { // Lovely Error Codes :-) //if ( $errorcodes[0] == "ename") // print "<style font-color:'red'>State / Territory Field Missing<br></style>"; //Lets set some background colors print "<body bgcolor=#ffffcc>"; if ( $errorcodes[0] == "ename") {print "<font color =red><b><ul type=circle><li>State / Territory Field Missing<br></font></b></ul></li>";} if ( $errorcodes[1] == "esnumber") {print "<font color =red><b><ul type=circle><li>Street Number Missing<br></font></b></ul></li>";} if ( $errorcodes[2] == "ecity") {print "<font color =red><b><ul type=circle><li>City Field Missing<br></font></b></ul></li>";} if ( $errorcodes[3] == "estate") {print "<font color =red><b><ul type=circle><li>State Field Missing<br></font></b></ul></li>";} if ( $errorcodes[4] == "ezip" ) {print "<font color =red><b><ul type=circle><li>Postal Code Field Missing<br></font></b></ul></li>";} if ( $errorcodes[5] == "ecountry") {print "<font color =red><b><ul type=circle><li>Country Field Missing<br></font></b></ul></li>";} // SUSPENDING PHP TO ALLOW HTML ?> <form name=form1 method=post action=http://mysite.net/phpharvest.php> <table border = "0" width="100%" cellpadding="5" cellspacing="0"> <tr> <td width="100"><b>Name*</b></td> <td><input type="text" name="db_name" value="<?=$db_name?>" size="25"></td> </tr> <tr> <td>Email</td> <td><input type="text" name="db_email" value="<?=$db_email?>" size="25"></td> </tr> <tr> <td>Company</td> <td><input type="text" name="db_company" value="<?=$db_company?>" size="25"></td> </tr> <tr> <td><b>Address 1*</b></td> <td><input type="text" name="db_snumber" value="<?=$db_snumber?>" size="25"></td> </tr> <tr> <td>Address 2</td> <td><input type="text" name="db_address2" value="<?=$db_address2?>" size="25"></td> </tr> <tr> <td><b>City</b>*</td> <td><input type="text" name="db_city" value="<?=$db_city?>" size="25"></td> </tr> <tr> <td><b>State / Territory*</b></td> <td><input type="text" name="db_state" value="<?=$db_state?>" size="25"></td> </tr> <tr> <td><b>Country*</b></td> <td><input type="text" name="db_country" value="<?=$db_country?>" size="25"></td> </tr> <tr> <td><b>Postal Code*</b></td> <td><input type="text" name="db_zip" value="<?=$db_zip?>" size="25"></td> </tr> <tr> <td>Phone</td> <td><input type="text" name="db_phone" value="<?=$db_phone?>" size="25"></td> </tr> <tr> <td>Fax</td> <td><input type="text" name="db_fax" value="<?=$db_fax?>" size="25"></td> </tr> <tr> <td> </td> <td> <input type="submit" name="submit"> <input type="reset" name="Reset"> </td> </tr> </table> </form></center> <?php } ?>
Newsform.html
<html> <head> <title>Untitled-4</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#ffffcc" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <center><br> <font color="white" size="4"> <b>Sign Up For Promotional News Letter</b></font> <form name=form1 method=post action=http://xxxx.com/~sssz/phpharvest.php> <table border = "0" width="100%" cellpadding="5" cellspacing="0"> <tr> <td width="100"><b>Name*</b></td> <td><input type="text" name="db_name" size="25"></td> </tr> <tr> <td>Email</td> <td><input type="text" name="db_email" size="25"></td> </tr> <tr> <td>Company</td> <td><input type="text" name="db_company" size="25"></td> </tr> <tr> <td><b>Address 1*</b></td> <td><input type="text" name="db_snumber" size="25"></td> </tr> <tr> <td>Address 2</td> <td><input type="text" name="db_address2" size="25"></td> </tr> <tr> <td><b>City</b>*</td> <td><input type="text" name="db_city" size="25"></td> </tr> <tr> <td><b>State / Territory*</b></td> <td><input type="text" name="db_state" size="25"></td> </tr> <tr> <td><b>Country*</b></td> <td><input type="text" name="db_country" size="25"></td> </tr> <tr> <td><b>Postal Code*</b></td> <td><input type="text" name="db_zip" size="25"></td> </tr> <tr> <td>Phone</td> <td><input type="text" name="db_phone" size="25"></td> </tr> <tr> <td>Fax</td> <td><input type="text" name="db_fax" size="25"></td> </tr> <tr> <td> </td> <td> <input type="submit" name="submit"> <input type="reset" name="Reset"> </td> </tr> </table> </form></center>
-
<?php $colors = array('#ffff23', '#faaf23', '#ff3323', '#f99f23', '#ff8823', '#fff773'); ?>
Then you call it by $colors[position] the position is the spot ur value is in so if u want #ffff23 it would be $colors[0]
-
Micah1701 was that legal in the unwritten bible of PHP? Thank You so much!
Grodo
-
Thanks for your input... I need all the html in a variable because its in the middle of a else statement. Unless if there is another option there are 108 quotes this is going to be fun!
else { // Lovely Error Codes :-) //if ( $errorcodes[0] == "ename") // print "<style font-color:'red'>State / Territory Field Missing<br></style>"; //Lets set some background colors print "<body bgcolor=#ffffcc>"; if ( $errorcodes[0] == "ename") {print "<font color ='red'><b><ul type="circle"><li>State / Territory Field Missing<br></font></b></ul></li>";} if ( $errorcodes[1] == "esnumber") {print "<font color ='red'><b><ul type="circle">Street Number Missing<br></font></b></ul></li>";} if ( $errorcodes[2] == "ecity") {print "<font color ='red'><b><ul type="circle">City Field Missing<br></font></b></ul></li>";} if ( $errorcodes[3] == "estate") {print "<font color ='red'><b><ul type="circle">State Field Missing<br></font></b></ul></li>";} if ( $errorcodes[4] == "ezip" ) {print "<font color ='red'><b><ul type="circle">Postal Code Field Missing<br></font></b></ul></li>";} if ( $errorcodes[5] == "ecountry") {print "<font color ='red'><b><ul type="circle">Country Field Missing<br></font></b></ul></li>";} print "$htmlcode"; }
-
Hello again I need help once more :-x
Ok so I created a post html page where the user fills out a form and it sends it to my PHP script using the $POST method. I have validated froms checking for input if non is given it prints an error message. Now here is my question how can I reload the form with the information that the vistor entered on the previous one. My HTML code is stored in a varible $htmlcode here is the code for it is below. This comes from the original html document that passed the value to PHP from the form. I tried to set the values of the input text box to strings; however that did not work. Here is what I used
<input type="text" name="db_fax" value="$db_fax" size="25">. For some reason the scipt didnt read the value of the string and put it as its value. It just filled the input text boxes with the name of the string($db_fax). To output the data is used print "$htmlcode"; method. If some one could tell me what Im doing that would be awesome.
Thank You
Grodo
Varible $htmlcode
$htmlcode = '<html><head><title>Untitled-4</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head><body bgcolor="#ffffcc" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><img src="gts.gif" width="100%" height="79" alt=""> <center><br><font color="white" size="4"> <b>Sign Up For Galaxy Tool Supply Promotional News Letter</b></font><form name=form1 method=post action=http://xxxxx.com/~gxxxx/xxxx.php> <table border = "0" width="100%" cellpadding="5" cellspacing="0"> <tr><td width="100"><b>Name*</b></td><td><input type="text" name="db_name" value="$db_name" size="25"></td></tr><tr><td>Email</td> <td><input type="text" name="db_email" value="$db_email" size="25"></td></tr><tr><td>Company</td><td><input type="text" name="db_company" value=" $db_company" size="25"></td></tr> <tr><td><b>Address 1*</b></td><td><input type="text" name="db_snumber" value="$db_snumber" size="25"></td></tr> <tr><td>Address 2</td><td><input type="text" name="db_address2" value="$db_address2" size="25"></td></tr><tr> <td><b>City</b>*</td><td><input type="text" name="db_city" value="$db_city"size="25"></td></tr><tr><td><b>State / Territory*</b></td> <td><input type="text" name="db_state" value="$db_state" size="25"></td></tr><tr><td><b>Country*</b></td><td><input type="text" name="db_country" value="$db_country" size="25"></td></tr> <tr><td><b>Postal Code*</b></td><td><input type="text" name="db_zip" value="$db_zip" size="25"></td> </tr><tr><td>Phone</td><td><input type="text" name="db_phone" value='$db_phone' size="25"></td></tr> <tr><td>Fax</td><td><input type="text" name="db_fax" value="$db_fax" size="25"></td></tr> <tr><td> </td><td><input type="submit" name="submit"> <input type="reset" name="Reset"></td></tr></table></form></center>';
Thank You Grodo
-
instead of using 100% for ur width value use an actual pixel value
-
This is my first time coding in php :-x I just kind of jumped into it I have 2 years of Java coding exp so it wasnt so bad. Thanks for all your help guys. LOL im just goign to drop this before a flame war breaks out over PHP echo vs print lol It be like the Nintendo Ds vs PSP fan boys; only change would be echo method vs print hahahaha! I like this community so lets keep the hatred out :-)
-
but the thing is that echo printed in black ink and print printed in the right color
-
Hmmm :-/ Then why does print work for me but echo does not? Must be a server issue then
-
I figured it out! I just used the print method instead of echo
Daniel0 was right echo command does not understand html.
this is my new code
print "<font color ='red'>State / Territory Field Missing<br></font>";
Thanx to every one who helped! I will donate to this great resource!
Grodo
-
Daniel0 Code fixed t_string error but still prints in black
is there another function to print out errors?
envexlabs: <p style="color: red;">Text</p> just made the T_String error occur
-
I removed the color tags and it works like a charm how ever only in black text. When I tried it with style I received a different error.
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/galaxyto/public_html/phpharvest.php on line 197
197 is the line with the font tags. I tried
<style font-color:"red">Error Text</style>
<style font-color:"red";>Error Text
Is there another way to print out text in PHP? I Know my code is messy sorry about that :-/
// Ok lets validate some parameters! With error reporting! //First we make an array to hold the error code information $errorcodes = array('ok', 'ok', 'ok', 'ok', 'ok', 'ok'); if ($db_name == "") { $errorcodes[0] = ename; } if ($db_snumber == "") { $errorcodes[1] = esnumber; } if ($db_city == "") { $errorcodes[2] = ecity; } if ($db_state == "") { $errorcodes[3] = estate; } if ($db_zip == "") { $errorcodes[4] = ezip; } if ($db_country == "") { $errorcodes[5] = ecountry; } // Code that gives the ok to process for ( $i = 0; $i<6; $i++ ) { if ( $errorcodes[$i] == "ok" ) { $process == TRUE; } else { $process == FALSE; } } if (isset($db_name) && isset($db_snumber) && isset($db_city) && isset($db_state) && isset($db_zip) && isset($db_country) && $process == TRUE) { // Write values to data files code if i posted it would be to long (the code works) } else { // Lovely Error Codes :-) if ( $errorcodes[0] == "ename") echo "<style font-color:"red">State / Territory Field Missing<br></style>"; if ( $errorcodes[1] == "esnumber") echo "Street Number Missing<br>"; if ( $errorcodes[2] == "ecity") echo "City Field Missing<br>"; if ( $errorcodes[3] == "estate") echo "State Field Missing<br>"; if ( $errorcodes[4] == "ezip" ) echo "Postal Code Field Missing<br>"; if ( $errorcodes[5] == "ecountry") echo "Country Field Missing<br>"; }
-
I cant figure out how to echo in a color.
Here is my code
echo "<font color='#ff1200'>State / Territory Field Missing<br></font>";
the error that i receive is
Parse error: parse error, unexpected T_IF in /home/galaxyto/public_html/phpharvest.php
I remove the font tag and the script works fine.
Thank You
Grodo
-
Problem solved I Guess .csv files dont like the \n return Changed it to a txt doc and it works like a charm. Thanks Kiss o Matic for your efforts... Cheers
$f_data = "\"$db_name\"\n\"$db_company\"\n\"$db_email\"\n\"$db_phone\"\n\"$db_address\"\n\"$db_address2\"\n\"$db_city\"\n\"$db_state\"\n\"$db_country\"\n\"$db_zip\"\n"; if (is_writable($csv_mailformat)) { if (fwrite($csv_mailformathandle, $f_data) === FALSE) { echo "Cannot write to file $csv_mail"; exit; } }
-
hmmmm that didnt work
However this works but only does one line
$csv_itemmaildata = "\"$db_name\",\"$db_company\",\"$db_email\",\"$db_phone\",\"$db_address\",\"$db_address2\",\"$db_city\",\"$db_state\",\"$db_country\",\"$db_zip\"\n"; if (is_writable($csv_mail)) { if (fwrite($csv_mailhandle, $csv_itemmaildata) === FALSE) { echo "Cannot write to file $csv_mail"; exit; } }
-
// Format Mail $fcsv_itemmaildata = "\"$db_name\"\n\"$db_company\"\n\"$db_email\"\n\"$db_phone\"\n\"$db_address\"\n\"$db_address2\"\n\"$db_city\"\n\"$db_state\"\n\"$db_country\"\n\"$db_zip\"\n"; if (is_writable($csv_mailformat)) { if (fwrite($csv_mailformathandle, $fcsv_itemmaildata) === FALSE) { echo "Cannot write to file $csv_mail"; exit; } } fclose($csv_mailformathandle);
-
I can write to one line but cant get it to do multiple of them
$csv_mailformat = file to write to
$fcsv_itemmaildata = The string that contains information to be written
$csv_mailformathandle = the pointer
I am really confused on why this wont work
Cheers,
Grodo
// Format Mail $csv_mailformathandlecode]
[SOLVED] Function not returning array
in PHP Coding Help
Posted
try print($new_array);