Jump to content

php_begins

Members
  • Posts

    259
  • Joined

  • Last visited

Everything posted by php_begins

  1. Thank you very much. Since i was calling PHP_SELF and calling out some php functions, i assumed someone with better knowledge of PHP syntax might be able to help me add html to my existing code..
  2. i tried something like this, but i am not sure of the syntax.. <? if(!empty($success_message)) { echo "<p class='#form'><center><font color='blue'><b>".$success_message."</b></font><br></p>"; } if(!empty($failure_message)) { echo "<p class='#form'><center><font color='red'><b>".$failure_message."</b></font><br></p>"; } ?> <? if((empty($_POST)) || !empty($strError)) { echo "<table align= 'center' width='70%' style='border-top: 1px; border-right: 1px; border-left: 1px; border-bottom: 1px; border-color: black; border-style: solid;'>"; ?> <tr> <td> <form action="<?php echo $PHP_SELF;?>" method="post" class="#form">
  3. hello, this is part of my contact form code. When i click on the submit button i need the form to take me to the $success_message or the $failure_message instead of the top of the page. I know i can do it with # tag or # id normally. But I do not know how to apply it to the form. //some text and stuff<tr> <td> <? if(!empty($success_message)) { echo "<center><font color='blue'><b>".$success_message."</b></font><br></p>"; } if(!empty($failure_message)) { echo "<center><font color='red'><b>".$failure_message."</b></font><br></p>"; } ?> <? if((empty($_POST)) || !empty($strError)) { echo "<table align= 'center' width='70%' style='border-top: 1px; border-right: 1px; border-left: 1px; border-bottom: 1px; border-color: black; border-style: solid;'>"; ?> <form action="<?php echo $PHP_SELF;?>" method="post"> <tr height='40'> <td> <font color="black"><B> First Name: </B></font> </td> <td><input type="text" size ="40" name="first_name" value="<? if(!empty($strError)) {echo cleaninput($_POST['first_name']);}?>" class="advertising-inputbox-style" /> <?php if (!empty($arrErrors['first_name'])) echo $arrErrors['first_name']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Last Name: </B></font></td> <td><input type="text" size ="40" name="last_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['last_name']);}?>" class="advertising-inputbox-style"/> <?php if (!empty($arrErrors['last_name'])) echo $arrErrors['last_name']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Email Address: </B></font></td> <td><input type="text" size ="40" name="email_address" value="<? if(!empty($strError)) { echo cleaninput($_POST['email_address']);}?>" class="advertising-inputbox-style"/> <?php if (!empty($arrErrors['email_address'])) echo $arrErrors['email_address']; ?> </td> </tr> <tr height='35'> <td><font color="black"><B> Business Name: </B></font></td> <td><input type="text" size ="40" name="business_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['business_name']);}?>" class="advertising-inputbox-style" /> <?php if (!empty($arrErrors['business_name'])) echo $arrErrors['business_name']; ?> </td> </tr> <tr> <td><font color="black"><B> Business Description: </B></font></td> <td ><textarea rows=7 cols=31 name="description" class="advertising-textarea-style"><? if(!empty($strError)) { echo cleaninput($_POST['description']);}?></textarea> <?php if (!empty($arrErrors['description'])) echo $arrErrors['description']; ?> </td> <tr height='35'> <td></td> <td><input type="submit" name="submit" value="submit" /></td> </tr> </form>
  4. the only reason i could think of is it is an md5 behaviour issue..
  5. could it be because there are numbers in that image too?
  6. if(strtolower(md5($_POST['security_word']).'a4xn') == strtolower($_COOKIE['tntcon'])) does not work either..
  7. i already tried that..but it didnt work: if(strtolower(md5($_POST['security_word'])).'a4xn' == strtolower($_COOKIE['tntcon']))
  8. I am using a captcha like image verification for my form fields. I want to make my check case insensitive: For example, if the security word is 1A3e then 1a3e or 1a3E should work.(Upper Case or lower case does not matter) Here is the check I am doin so far to see if my security word matches. if(md5($_POST['security_word']).'a4xn' == $_COOKIE['tntcon'])
  9. the secuirty code is autogenerated random text and numbers. I want it to able to use it like CAPTCHA. Is there an alternate method..can i make that code into an image or something?
  10. can u make a form field not copyable. I have the following field. but i do not want users to able to copy and paste it.. <input type="text" size="40" name="security_code" value="72o936GRWD" readonly="">
  11. i have a code that generates a random code and displays it as an image. But the problem the image can be displayed only if it is called before any other output. How do i run it so that it can be displayed after any output.. <? //Security Word for the form $codelenght = 10; while($newcode_length < $codelenght) { $x=1; $y=3; $part = rand($x,$y); if($part==1){$a=48;$b=57;} // Numbers if($part==2){$a=65;$b=90;} // UpperCase if($part==3){$a=97;$b=122;} // LowerCase $code_part=chr(rand($a,$b)); $newcode_length = $newcode_length + 1; $newcode = $newcode.$code_part; } header('Content-Type: image/png'); $im = imagecreatetruecolor(200, 40); $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $blue = imagecolorallocate($im, 0, 0, 238); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 1, 1, 200, 40, $white); $font = '/home/vhosts/master_files/advertising/fonts/arialbd.ttf'; imagettftext($im, 12, 0, 10, 18, $blue, $font, $newcode); imagepng($im); imagedestroy($im); ?>
  12. hi i have the following contact us form which works fine. i need lil more tweaking. Right now when i submit the form it displays the information "blah blah", "the form has been submitted successfully" and also the form. What i want to do is if the form has been submitted successfully i need not display the form again. I need to display the data before the form field: "Blah Blah"(information before the form code) "the form has been submitted successfully" I do not need to display the form if it has been a successful submission. here is my code: <?php include($headerpath); //change this to use mysql count function $totalentriesrow = mysql_query("SELECT DISTINCT userid FROM user", $con); $totalentriesrow = mysql_num_rows($totalentriesrow); ?> <title><?PHP echo $site_name; ?> Advertising</title> <BR><BR> <table cellpadding="5" cellspacing="1" bgcolor="white" border="0" width="900" align="center" style='border-top: 1px; border-right: 1px; border-left: 1px; border-bottom: 1px; border-color: black; border-style: solid;'> <tr> <td bgcolor='<?PHP echo $head; ?>' align='left'><b><font color='<?PHP echo $head_font_color; ?>' size='2' face='verdana'><?PHP echo $site_name; ?> Advertising</font></b> Blah Blah Blah Blah </td> </tr> <? //echo '<center><h4><font color="blue"><br>CONTACT US<br></font></h4></center>'; // Create an empty array to hold the error messages. $arrErrors = array(); //Only validate if the Submit button was clicked. if (!empty($_POST['submit'])) { // Each time theres an error, add an error message to the error array // using the field name as the key. if (empty($_POST['first_name'])) $arrErrors['first_name'] = '<br><font color="red">Please provide your first name.</font>'; if (empty($_POST['last_name'])) $arrErrors['last_name'] = '<br><font color="red">Please provide your last name.</font>'; if (empty($_POST['business_name'])) $arrErrors['business_name'] = '<br><font color="red">Please provide your business name.</font>'; if (empty($_POST['website_url'])) $arrErrors['website_url'] = '<br><font color="red">Please provide a website url.</font>'; if (empty($_POST['street_address'])) $arrErrors['street_address'] = '<br><font color="red">Please provide your street address.</font>'; if (empty($_POST['city'])) $arrErrors['city'] = '<br><font color="red">Please provide your city name.</font>'; if (empty($_POST['state'])) $arrErrors['state'] = '<br><font color="red">Please provide your state.</font>'; if (empty($_POST['zip'])) $arrErrors['zip'] = '<br><font color="red">Please provide your zip.</font>'; if (empty($_POST['country'])) $arrErrors['country'] = '<br><font color="red">Please provide your country.</font>'; if (empty($_POST['email_address'])) $arrErrors['email_address'] = '<br><font color="red">A valid email address is required.</font>'; if (empty($_POST['phone']) || (!is_numeric($_POST['phone']))) $arrErrors['phone'] = '<br><font color="red">Phone number cannot be empty and has to be numeric.</font>'; if (empty($_POST['description'])) $arrErrors['description'] = '<br><font color="red">Description cannot be empty.</font>'; // If the error array is empty, there were no errors. // Insert form processing here. if (count($arrErrors) == 0) { $first_name=cleaninput($_POST['first_name']); $last_name=cleaninput($_POST['last_name']); $business_name=cleaninput($_POST['business_name']); $website_url=cleaninput($_POST['website_url']); $street_address=cleaninput($_POST['street_address']); $city=cleaninput($_POST['city']); $state=cleaninput($_POST['state']); $zip=cleaninput($_POST['zip']); $country=cleaninput($_POST['country']); $email_address=cleaninput($_POST['email_address']); $phone=cleaninput($_POST['phone']); $description=cleaninput($_POST['description']); $to = $advertising_contacts; $subject = "Advertisement Contact"; $message="You have a new advertising contact<br>"; $message.="<b>First name:</b> ".stripslashes($first_name)."<br><b>Last Name:</b> ".stripslashes($last_name); $message.="<br><b>Business Name:</b> ".stripslashes($business_name)."<br><b>Business Description: </b>".stripslashes($description)."<br><b>Business URL:</b> ".stripslashes($website_url); $message.="<br><b>Street Address:</b> ".stripslashes($street_address)."<br><b>City:</b> ".stripslashes($city); $message.="<br><b>State:</b> ".stripslashes($state)."<br><b>Zip:</b> ".stripslashes($zip)."<br><b>Country:</b> ".stripslashes($country); $message.="<br><b>Email:</b> ".stripslashes($email_address)."<br><b>Phone:</b> ".stripslashes($phone); $from = "webmaster@example.com"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Admin <Admin@groupbuilder.com>' . "\r\n"; // Send email mail($to,$subject,$message,$headers); //escapeinput for inserting into database $first_name=escapeinput($first_name); $last_name=escapeinput($last_name); $website_url=escapeinput($website_url); $street_address=escapeinput($street_address); $city=escapeinput($city); $state=escapeinput($state); $zip=escapeinput($zip); $country=escapeinput($country); $email=escapeinput($email); $phone=escapeinput($phone); $description=escapeinput($description); $dateline=time(); //Insert the details into database $insert_contacts=mysql_query("INSERT INTO adcontacts(first_name,last_name,email_address,phone,business_name,description,website_url,street_address,city,state,zip,country,dateline) VALUES('$first_name','$last_name','$email_address','$phone','$business_name','$description','$website_url','$street_address','$city','$state','$zip','$country','$dateline')") or die(mysql_error()); echo "<center>Form Submitted Successfully</center><br>"; } else { // The error array had something in it. There was an error. // Start adding error text to an error string. echo "<center>There was an error in the form<br></center>"; $strError=""; foreach ($arrErrors as $error) { $strError .= $error; } } } ?> <tr> <td> <? echo "<table align= 'center' width='50%' style='border-top: 1px; border-right: 1px; border-left: 1px; border-bottom: 1px; border-color: black; border-style: solid;'>"; ?> <tr> <td> <form action="<?php echo $PHP_SELF;?>" method="post"> <tr height='40'> <td> <font color="black"><B> First Name: </B></font> </td> <td><input type="text" size ="40" name="first_name" value="<? if(!empty($strError)) {echo cleaninput($_POST['first_name']);}?>" /> <?php if (!empty($arrErrors['first_name'])) echo $arrErrors['first_name']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Last Name: </B></font></td> <td><input type="text" size ="40" name="last_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['last_name']);}?>"/> <?php if (!empty($arrErrors['last_name'])) echo $arrErrors['last_name']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Email Address: </B></font></td> <td><input type="text" size ="40" name="email_address" value="<? if(!empty($strError)) { echo cleaninput($_POST['email_address']);}?>"/> <?php if (!empty($arrErrors['email_address'])) echo $arrErrors['email_address']; ?> </td> </tr> <tr height='35'> <td><font color="black"><B> Business Name: </B></font></td> <td><input type="text" size ="40" name="business_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['business_name']);}?>" /> <?php if (!empty($arrErrors['business_name'])) echo $arrErrors['business_name']; ?> </td> </tr> <tr> <td><font color="black"><B> Business Description: </B></font></td> <td ><textarea rows=7 cols=31 name="description"><? if(!empty($strError)) { echo cleaninput($_POST['description']);}?></textarea> <?php if (!empty($arrErrors['description'])) echo $arrErrors['description']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Business URL: </B></font></td> <td><input type="text" size ="40" name="website_url" value="<? if(!empty($strError)) { echo cleaninput($_POST['website_url']);}?>" /> <?php if (!empty($arrErrors['website_url'])) echo $arrErrors['website_url']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Business Phone: </B></font></td> <td><input type="text" size ="40" name="phone" value="<? if(!empty($strError)) { echo cleaninput($_POST['phone']);}?>"/> <?php if (!empty($arrErrors['phone'])) echo $arrErrors['phone']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Street Address: </B></font></td> <td><input type="text" size ="40" name="street_address" value="<? if(!empty($strError)) { echo cleaninput($_POST['street_address']);}?>" /> <?php if (!empty($arrErrors['street_address'])) echo $arrErrors['street_address']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> City: </B></font></td> <td><input type="text" size ="40" name="city" value="<? if(!empty($strError)) { echo cleaninput($_POST['city']);}?>" /> <?php if (!empty($arrErrors['city'])) echo $arrErrors['city']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> State: </B></font></td> <td><input type="text" size ="40" name="state" value="<? if(!empty($strError)) { echo cleaninput($_POST['state']);}?>"/> <?php if (!empty($arrErrors['state'])) echo $arrErrors['state']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Zip: </B></font></td> <td><input type="text" size ="40" name="zip" value="<? if(!empty($strError)) { echo cleaninput($_POST['zip']);}?>"/> <?php if (!empty($arrErrors['zip'])) echo $arrErrors['zip']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Country: </B></font></td> <td> <select name="country"> <option value="<? if(!empty($strError)) { echo $_POST['country'];}?>"><?echo cleaninput($_POST['country']);?></option> <?php foreach($array as $key=>$value){ ?> <option value="<?php echo $value; ?>"><?php echo $value; ?></option> <?php }?> </select> <?php if (!empty($arrErrors['country'])) echo $arrErrors['country']; ?> </td> </tr> <tr height='35'> <td></td> <td><input type="submit" name="submit" value="submit" /></td> </tr> </form> </tr> </td> </table> </td> </tr> </table>
  13. never mind..i added a <tr> and <td> before the 2nd table and it worked..
  14. I have the following code which has a table nested inside a table. But the nested table does not seem to fall inside the box. i.e inside the first table. It displays outside the border line. can someone point out the flaw in my code: here is my code: <table cellpadding="5" cellspacing="1" bgcolor="#DDEEFF" border="0" width="900" align="center" style='border-top: 1px; border-right: 1px; border-left: 1px; border-bottom: 1px; border-color: black; border-style: solid;'> <tr> <td bgcolor='#40382b' align='left'><b><font color='#FFFFFF' size='2' face='verdana'>our Forum Advertising</font></b></td> </tr> <tr> <td bgcolor='white'align='left'><br> <font face="Verdana" size="4" color='black'><B>Advertising Overview</B></font> <font face="Verdana" size="2" color='black'>Advertising at our Forum gives you direct access to the exact market you are looking to advertise to. Our dedicated audience of jeep our enthusiasts are here to learn, be entertained and buy products. As print magazines decline, online magazines like our Forum are filling the void for readers. We are fast become a major locale for articles, reviews, tutorials, photos, classifieds and discussion.</font> <font face="Verdana" size="4" color='black'><B>Advertising Options</B></font> <font face="Verdana" size="2" color='black'>We offer a variety of advertising and sponsorship options, from large campaigns for retailers, to small campaigns for custom shops. Our proprietary advertising application gives us a lot of flexiblity to come up with a plan that works for you. We offer you the ability to upload banners yourself if you desire. You also have the option to run multiple banners in your ad slot to see which one works best for you. If you lack a graphical banner, our system allows you to create your own text based advertisement in minutes. Advertising options include; <ul> <li>Vendor Program</li> <li>Banner Advertising</li> <li>Newsletter Advertising</li> </ul> </td> </tr> <table align= 'center' width='50%' bgcolor='#5B6451'><tr> <td> <form action="" method="post"> <tr height='40'> <td> <font color="white"><B> First Name: </B></font> </td> <td><input type="text" size ="40" name="first_name" value="" /> </td> </tr> <tr height='40'> <td><font color="white"><B> Last Name: </B></font></td> <td><input type="text" size ="40" name="last_name" value=""/> </td> </tr> <tr height='35'> <td></td> <td><input type="submit" name="submit" value="submit" /></td> </tr> </form> </tr> </td> </table> </table>
  15. like i said the adid field is empty in the database table in some cases.(there is no value for adid in the table even when there are userids) so i want to select userid from the ad table where adid=NULL or ' ') this would still give me the userids. But unfortunately it does not return anything..i do not know to how to check for fields tht have no value..
  16. i still want to execute the query if the the adid field is empty or null. in some places adid is stored as empty(there is no value in the database table.) i still need to compare those values in the table nad execute. Right now if the adid field is empty it does not return anything.. Note: adid is not a primary key.it can be null
  17. i retrieving an adid from $_GET which is also a value retireved from a database. $this_adid=$_GET['adid']; if(empty($this_adid)) { $get_ad_id = mysql_query("SELECT userid FROM ads WHERE adid='$this_adid'", $con) or die("Error Getting AD ID: ".mysql_error()); while($get_ad_id_results = mysql_fetch_assoc($get_ad_id)) { $owner_id=$get_ad_id_results['userid']; } } the above query works if $this_adid returns 0 (http://www.website.com/?do=delete&adid=0&givenuserid=15773) i.e. adid is 0 in the table. But it does not work if $this_adid returns null or ntohin (http://www.website.com/?do=delete&adid=&givenuserid=15773) .i.e adid is ' ' (empty) field in the databse table.. can someone tell me why it does not check for null or empty values properly?
  18. Thank you quickoldcar.. MJ, ill keep that in mind
  19. i was working on modifying a code written by a previous user. i have field called adid in the ads table which should have been a primary key and autoincremented. But since we already have lot of data across different sites we cannot modify the table structure. The problem is i want to check if the following code is adding adid manually.is there some problem with this code? $get_ad_id = mysql_query("SELECT adid FROM ads ORDER BY adid DESC LIMIT 1", $con) or die("Error Getting AD ID: ".mysql_error()); while($get_ad_id_results = mysql_fetch_assoc($get_ad_id)) { $adid=$get_ad_id_results['adid']; } if($adid!="") { $adid=$adid+1; } else { $adid="1"; } if($bannertype=="120x60" || $bannertype=="468x60") { $New_URL = $_POST['URL']; $active='Y'; $insert_image_banner_query="INSERT INTO ads (adid, URL, image_path, date, userid, active, size) VALUES ('".$adid."','$New_URL', '$newname', '$Date', '$loggedinuserid','".$active."','".$bannertype."')"; mysql_query($insert_image_banner_query, $con) or die("Inserting Image Ad Failed: ".mysql_error()); $update_banner_cache="YES"; }
  20. <script type="text/javascript"> function toggleMe(a){ var e=document.getElementById(a); if(!e)return true; if(e.style.display=="none"){ e.style.display="block" } else { e.style.display="none" } return true; } </script> <input type="button" class="button" onclick="return toggleMe('para1')" value="Show all Banners"> <div id="para1" style="display:none"> <? $allbanners=mysql_query("SELECT * from ads where active='Y' ) or die(mysql_error()); while($allbanners_results = mysql_fetch_assoc($allbanners)) { $banner_image_path = $allbanners_results['image_path']; $banner_url = $allbanners_results['URL']; $banner_title = $allbanners_results['title']; echo "<tr><td width='468' align='left'><a href='".$banner_url."'><B><font size='3' face='arial'>".$banner_title."</font></B><img border=0 src='./images/" . $banner_image_path . "'></a></td></tr>"; echo "testing" } ?> </div> the above code works for only text expansion but does not expand or hide images..why is that so?
  21. i need to be able to expand and hide images too when i click on a button.. <script type="text/javascript"> function toggleMe(a){ var e=document.getElementById(a); if(!e)return true; if(e.style.display=="none"){ e.style.display="block" } else { e.style.display="none" } return true; } </script> <input type="button" class="button" onclick="return toggleMe('para1')" value="Show all Banners"> <div id="para1" style="display:none"> <? $allbanners=mysql_query("SELECT * from ads where active='Y' ) or die(mysql_error()); while($allbanners_results = mysql_fetch_assoc($allbanners)) { $banner_image_path = $allbanners_results['image_path']; $banner_url = $allbanners_results['URL']; $banner_title = $allbanners_results['title']; echo "<tr><td width='468' align='left'><a href='".$banner_url."'><B><font size='3' face='arial'>".$banner_title."</font></B><img border=0 src='./images/" . $banner_image_path . "'></a></td></tr>"; echo "testing" } ?> </div> The above code works only for text expansion. i want to expand and hide images upon click 'Show All Banners'
  22. I have no clue about to go abt this one: I have form which has some: <table> <tr> <td> <form> Title display info </form> </td> </tr> </table> I need to add an additional link next to title such that when someone clicks on the link the table expands and displays rsult of a query. <table> <tr> <td> <form> Title LINK if( link is clicked ) { $query=select display query results } else { dont display query results display info } </form> </td> </tr> </table>
  23. well they just break randomly without any reason at times.For example: TJDaddy;gotjeep;FLHT_FXRS_YJ;jpwranglr9;sport;itsrich;OhYeah;RodeoRob;TNJeepMan;pm203;CETROV;'drack;ATeamer;Jeepchik;dooz;TJBrowder;dirtpilot;OverTheHandlebars;DCBerry;jeep thrills;OwnAccord;tpaudet;aroberts;MarkK;
  24. The following code returns thousands of results separated by a semicolon; while($getpostid_result=mysql_fetch_array($getpostid)) { $postusername=$getpostid_result['username']; echo $postusername.";"; } the problem is it does not print everything in one row.it breaks into the nextline after if it encounters certain chatacters or some other reason. I want it to able to print everything in one row irrespective of the number of results returned.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.