Jump to content

php-newbies

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Everything posted by php-newbies

  1. ok, I will go through those files to see if I can find the import.php and try commenting the line out. Will report back. Thanks for your time
  2. thanks for your reply, what other 4 files you referring to?
  3. This is the problem. I do not know why the script will invoke the include import.php from framework.php when it is not even mentioned in the pay_paypal.notify.php http://tt.easy2sell.net/components/com_adsman/plugins/payment/pay_paypal.notify.php
  4. Warning: require_once(/home/bgcomp/public_html/tt/components/com_adsman/plugins/payment/../../../../../../libraries/import.php) [function.require-once]: failed to open stream: No such file or directory in /home/bgcomp/public_html/tt/includes/framework.php on line 39 Fatal error: require_once() [function.require]: Failed opening required '/home/bgcomp/public_html/tt/components/com_adsman/plugins/payment/../../../../../../libraries/import.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/bgcomp/public_html/tt/includes/framework.php on line 39 This the url: http://tt.easy2sell.net/components/com_adsman/plugins/payment/pay_paypal.notify.php
  5. Thanks yes, they are in the same directory/folder. Have tried with brackets require_once ('pay_paypal.loadframework.php'); or without brackets, require_once 'pay_paypal.loadframework.php';but still gives error. I am really not sure what is causing it. Thanks once again.
  6. Thanks this is the script "pay_paypal.notify.php" below <?php // no direct access header("Status: 200 OK"); require_once(dirname(__FILE__)."/pay_paypal.loadframework.php"); $database = & JFactory::getDBO(); require_once(JPATH_ADMINISTRATOR.'/components/com_adsman/tables/addsman.php'); require_once(JPATH_ADMINISTRATOR.'/components/com_adsman/tables/adsuser.php'); require_once(dirname(__FILE__)."/pay_paypal.php"); $payment = new pay_paypal($database); $payment->ipn($_REQUEST); ?> Normally if the script runs ok, it should give me a blank page but will log it the backend http://tt.easy2sell.net/components/com_adsman/plugins/payment/pay_paypal.notify.php Many thanks for your help in advance.
  7. I believe there is a problem with the path to this file. what would be the alternative way to define the path? require_once(dirname(__FILE__)."/pay_paypal.loadframework.php"); The physical path to this file is located in my root folder. i.e root/components/com_ad/plugins/payment/pay_paypal.loadframework.php is it possible to change require_once to include the relative path and how do I do this? Many thanks in advance.
  8. Hi all, I need help, I am unable to access the url for my paypal. It gives an error when I paste the url on the browser. url is: http://tt.easy2sell.net/components/com_adsman/plugins/payment/pay_paypal.notify.php Wondering if I could try the relative path in the require once notify.php but unsure how? Perhaps problem with joomla installation file. <?php // no direct access header("Status: 200 OK"); require_once(dirname(__FILE__)."/pay_paypal.loadframework.php"); $database = & JFactory::getDBO(); /* $logfile=JPATH_ROOT."/a_paypal_ipn.log"; $fp=fopen($logfile,"w+"); fwrite($fp, print_r($_REQUEST,true) . "\n\n"); fwrite($fp, print_r($_SERVER,true) . "\n\n"); fclose($fp); // close file */ require_once(JPATH_ADMINISTRATOR.'/components/com_adsman/tables/addsman.php'); require_once(JPATH_ADMINISTRATOR.'/components/com_adsman/tables/adsuser.php'); require_once(dirname(__FILE__)."/pay_paypal.php"); $payment = new pay_paypal($database); $payment->ipn($_REQUEST); ?> Many thanks in advance
  9. Please I need your help, I need to display root category and its sub-category data in 3 columns. The problem I have is that the code is not adding rows, every time I add new category it just create a new column instead of adding new row. {include file='t_javascript_language.tpl'} {set_css} {set_js} <!--<div class="componentheading">{$page_title}</div>--> <div class="adds_man_list"> <span>{$category_pathway}</span> {if $current_category->catname!=""} <div style="border:2px solid #000;"> {include file='elements/display_fields.tpl' position='categoryicon' this_add=$current_category->id} <strong>{$current_category->catname}</strong> <div class="adds_subcat" style="text-align:right;background:#F5F5F5; border:1px solid #FFFFFF; " > {include file='elements/display_fields.tpl' position='categorydetails' this_add=$current_category->id} <span style="font-size:12px;"> {jtext text="ADS_SUBCATEGORIES"}: {$current_category->kids} {jtext text="ADS_ADS"}: {$current_category->nr_ads} <a href="{$current_category->view}" title="{jtext text='ADS_VIEW_LISTINGS'}"> <img src="{$IMAGE_ROOT}view_listings.gif" class="ads_noborder" alt="{jtext text='ADS_VIEW_LISTINGS'}" /> </a> </span> </div> </div> {/if} {if $categories|@count<=0} <h2>{jtext text="ADS_NO_CATEGORIES_DEFINED"}</h2> {/if} <table id="adds_categories" class="ads_table"> <tr> {assign var="col" value="0"} {section name=category loop=$categories} {if $col == $numCols} </tr><tr>{assign var="col" value="0"} {/if} <td width="16.6%" class="adsman_catcell" valign="top"> <div class="adds_maincat" {if $categories[category]->watchListed_flag}class="cat_watchlist"{/if}> {include file='elements/display_fields.tpl' position='categoryicon' this_add=$categories[category]->id} <a href="{if $categories[category]->kids>0}{$categories[category]->link}{else}{$categories[category]->view}{/if}" > {$categories[category]->catname} </a> {if $categories[category]->is_new} <!--NEW!!--> <img src="{$IMAGE_ROOT}new.png" alt="new ads" /> {/if} <a href="{$categories[category]->view}" title="{jtext text='ADS_VIEW_LISTINGS'}"> <img src="{$IMAGE_ROOT}view_listings.gif" class="ads_noborder" alt="{jtext text='ADS_VIEW_LISTINGS'}" /> </a> {if $is_logged_in} {if $categories[category]->watchListed_flag} <img src="{$IMAGE_ROOT}watchlist.png" width="16"class="ads_noborder" /> {/if} <a href="{$categories[category]->link_watchlist}"> <img src="{$categories[category]->img_src_watchlist}" width="16" class="ads_noborder" title="{if $categories[category]->watchListed_flag}{jtext text='ADS_REMOVE_FROM_WATCHLIST'}{else}{jtext text='ADS_ADD_TO_WATCHLIST'}{/if}"/> </a> {/if} <br /> </div> <div class="adds_subcat" style="background:#F5F5F5; border:1px solid #FFFFFF; " > {include file='elements/display_fields.tpl' position='categorydetails' this_add=$categories[category]->id} <br /> {section name=subcategory loop=$categories[category]->subcategories} {include file='elements/display_fields.tpl' position='categoryicon' this_add=$categories[category]->subcategories[subcategory]->id} <a href="{if $categories[category]->subcategories[subcategory]->kids>0}{$categories[category]->subcategories[subcategory]->link}{else}{$categories[category]->subcategories[subcategory]->view}{/if}">{$categories[category]->subcategories[subcategory]->catname}</a> {if $categories[category]->subcategories[subcategory]->is_new==1} <img src="{$IMAGE_ROOT}new.png" alt="new ads" /> {/if} ({$categories[category]->subcategories[subcategory]->nr_a} {jtext text="ADS_ADS"}) {if $categories[category]->subcategories[subcategory]->watchListed_flag} <img src="{$IMAGE_ROOT}watchlist.png" width="16" class="ads_noborder" /> {/if} {if $is_logged_in} <a href="{$categories[category]->subcategories[subcategory]->link_watchlist}"> <img src="{$categories[category]->subcategories[subcategory]->img_src_watchlist}" width="14" class="ads_noborder" title="{if $categories[category]->subcategories[subcategory]->watchListed_flag}{jtext text='ADS_REMOVE_FROM_WATCHLIST'}{else}{jtext text='ADS_ADD_TO_WATCHLIST'}{/if}"/> </a> {/if} <br /> <p style="margin-left:25px;"> {include file='elements/display_fields.tpl' position='categorydetails' this_add=$categories[category]->id} </p> {/section} </div> </td> {assign var="col" value="`$col+1`"} {/section} {assign var="remainder" value="`$numCols-$col`"} {section name=emptyElement loop=$remainder} <td> </td> {/section} </tr> </table> </div> Many thanks in advance for your help
  10. Thanks again for your help. Just an update, the code is adding extra rows each time I add a new category. I wanted to have 4 fixed columns and unlimited number of rows. Perhaps it is because I did not specify a variable for numCols as I am unsure about that. I really appreciate all your effort in modifying the code.
  11. Thank you so much, the code added 3 extra columns. The widths are not even. Trying to figure out how make the columns width the same width. It will definitively looks good when it finished. I really appreciate all your effort in modifying the code. I did not add any variable, I am a bit unsure about it.
  12. The output of the code is here http://tt.easy2sell.net Any suggestion or help will be highly appreciated. Many thanks in advance
  13. No you are not offending anyone. It is a nightmare for me trying to add the extra column, just don't know how. I did not even realize the extension is a tpl. Well any help will be highly appreciated. Thanks for the help so far
  14. Hi all, This application is given me a nightmare. The code fetches root categories and its sub categories from the a database table. The div table have only 2 columns. I want to add 2 extra columns so that I have 4 columns. Because we have a long list of subcategories meaning I have to scroll down to view the category. Please help {include file='t_javascript_language.tpl'} {set_css} {set_js} <!--<div class="componentheading">{$page_title}</div>--> <div class="adds_man_list"> <span>{$category_pathway}</span> {if $current_category->catname!=""} <div style="border:2px solid #000;"> {include file='elements/display_fields.tpl' position='categoryicon' this_add=$current_category->id} <strong>{$current_category->catname}</strong> <div class="adds_subcat" style="text-align:right;background:#F5F5F5; border:1px solid #FFFFFF; " > {include file='elements/display_fields.tpl' position='categorydetails' this_add=$current_category->id} <span style="font-size:12px;"> {jtext text="ADS_SUBCATEGORIES"}: {$current_category->kids} {jtext text="ADS_ADS"}: {$current_category->nr_ads} <a href="{$current_category->view}" title="{jtext text='ADS_VIEW_LISTINGS'}"> <img src="{$IMAGE_ROOT}view_listings.gif" class="ads_noborder" alt="{jtext text='ADS_VIEW_LISTINGS'}" /> </a> </span> </div> </div> {/if} {if $categories|@count<=0} <h2>{jtext text="ADS_NO_CATEGORIES_DEFINED"}</h2> {/if} <table id="adds_categories" class="ads_table"> {section name=category loop=$categories} {if $smarty.section.category.rownum is odd} <tr> {/if} <td width="50%" class="adsman_catcell" valign="top"> <div class="adds_maincat" {if $categories[category]->watchListed_flag}class="cat_watchlist"{/if}> {include file='elements/display_fields.tpl' position='categoryicon' this_add=$categories[category]->id} <a href="{if $categories[category]->kids>0}{$categories[category]->link}{else}{$categories[category]->view}{/if}" > {$categories[category]->catname} </a> {if $categories[category]->is_new} <!--NEW!!--> <img src="{$IMAGE_ROOT}new.png" alt="new ads" /> {/if} <a href="{$categories[category]->view}" title="{jtext text='ADS_VIEW_LISTINGS'}"> <img src="{$IMAGE_ROOT}view_listings.gif" class="ads_noborder" alt="{jtext text='ADS_VIEW_LISTINGS'}" /> </a> {if $is_logged_in} {if $categories[category]->watchListed_flag} <img src="{$IMAGE_ROOT}watchlist.png" width="16"class="ads_noborder" /> {/if} <a href="{$categories[category]->link_watchlist}"> <img src="{$categories[category]->img_src_watchlist}" width="16" class="ads_noborder" title="{if $categories[category]->watchListed_flag}{jtext text='ADS_REMOVE_FROM_WATCHLIST'}{else}{jtext text='ADS_ADD_TO_WATCHLIST'}{/if}"/> </a> {/if} <br /> </div> <div class="adds_subcat" style="background:#F5F5F5; border:1px solid #FFFFFF; " > {include file='elements/display_fields.tpl' position='categorydetails' this_add=$categories[category]->id} <br /> {section name=subcategory loop=$categories[category]->subcategories} {include file='elements/display_fields.tpl' position='categoryicon' this_add=$categories[category]->subcategories[subcategory]->id} <a href="{if $categories[category]->subcategories[subcategory]->kids>0}{$categories[category]->subcategories[subcategory]->link}{else}{$categories[category]->subcategories[subcategory]->view}{/if}">{$categories[category]->subcategories[subcategory]->catname}</a> {if $categories[category]->subcategories[subcategory]->is_new==1} <img src="{$IMAGE_ROOT}new.png" alt="new ads" /> {/if} ({$categories[category]->subcategories[subcategory]->nr_a} {jtext text="ADS_ADS"}) {if $categories[category]->subcategories[subcategory]->watchListed_flag} <img src="{$IMAGE_ROOT}watchlist.png" width="16" class="ads_noborder" /> {/if} {if $is_logged_in} <a href="{$categories[category]->subcategories[subcategory]->link_watchlist}"> <img src="{$categories[category]->subcategories[subcategory]->img_src_watchlist}" width="14" class="ads_noborder" title="{if $categories[category]->subcategories[subcategory]->watchListed_flag}{jtext text='ADS_REMOVE_FROM_WATCHLIST'}{else}{jtext text='ADS_ADD_TO_WATCHLIST'}{/if}"/> </a> {/if} <br /> <p style="margin-left:25px;"> {include file='elements/display_fields.tpl' position='categorydetails' this_add=$categories[category]->id} </p> {/section} </div> </td> {if $smarty.section.category.rownum is not odd} </tr> {/if} {/section} </table> </div> Many thanks
  15. Thanks for the help, could you please comment what each line of code does. Thanks.
  16. I have been struggling with this code but still having problem. Any help will be highly appreciated. This is the new function I am trying to run but keep getting error. I have this code on the submit.php file, but I am getting a syntax error. function check_fields() { $HTTP_POST_VARS['brief']=preg_replace("/0,1,2,3,4,5,6,7,8,9/", /www/",/@/",""$HTTP_POST_VARS['brief']); } Many thanks
  17. Hi all, I have a textarea field name brief in my php form. The problem is that users are entering phone numbers and email addresses in this field even though there is dedicated email and phone fields. I want a function to either delete the numbers and emails address automatically on this field or alert the user that numbers are not allowed in this field. I have include my form. Many thanks for your help 17684_.zip
  18. Hi again, Where can I run this code? When I login into the phpmyadmin I can see the import button and when click , it ask for where to import data from but there is no place to place the code above. I have the csv files containing names of the cities for each individual states, each csv is unique to individual states. I know I have to import each csv 1 after the other for each states. But I cannot find where to run the code you provided above. Please help with abit of step by step. Many thanks for your help.
  19. Thank you for your response. I will try it out later and will report back. thanks again for your help.
  20. Hi all, I have a table name states and I have 20 different states under this table. I want to import csv file that contains names of cities that belongs to each states. I am new to mysql and I am not such where to start. I have a web based application that I need to input these data. I have access to phpmyadmin through my hosting control panel. Please help. Thank you in advance for your help.. Regards, Mark
  21. Merry xmas and happy new in advance to you all. I have a web form where user submit an ad. Everything is working just fine. However there is a field name brief. The brief field is where user add info about their ad. Now people are including web url, phone numbers and email address in this field which make the ad look like spam. In the code there is already a function that check if they have entered their email address in the email field. I want to add a function to the check field to include the brief field. The function should either automatically delete any phone number/email addr/web url or replace with with my website name if detected in the brief field. Your help will be highly appreciated. <?php function check_fields() { global $db_entry, $visible_val, $cat_fields, $email, $HTTP_POST_VARS, $photos_count, $phptomaxsize, $userfile, $prviewphotomax, $incl_prevphoto, $incl_mtmdfile, $mtmdfile_maxs, $userfile_name, $select_text, $msg2; if(!get_magic_quotes_gpc()) { foreach ($HTTP_POST_VARS as $key5 => $value ) { $HTTP_POST_VARS[$key5]=addslashes($HTTP_POST_VARS[$key5]); } } foreach ( $cat_fields as $key => $value ) { $HTTP_POST_VARS[$key]=ereg_replace('<', '&#060;', $HTTP_POST_VARS[$key]); $HTTP_POST_VARS[$key]=ereg_replace('>', '&#062;', $HTTP_POST_VARS[$key]); if ($cat_fields[$key][2]=="minmax") { $HTTP_POST_VARS[$key]=ereg_replace(',', '', $HTTP_POST_VARS[$key]); $HTTP_POST_VARS[$key]=preg_replace ('/[A-Za-z]|\$|,|\?|\+/', "", $HTTP_POST_VARS[$key]); } if ($cat_fields[$key][4]=="date") { $key_d=$key."_dd"; $key_m=$key."_mm"; $key_y=$key."_yy"; $HTTP_POST_VARS[$key]=$HTTP_POST_VARS[$key_y]."-".$HTTP_POST_VARS[$key_m]."-".$HTTP_POST_VARS[$key_d]; if (($HTTP_POST_VARS[$key_m] > 12) or ($HTTP_POST_VARS[$key_m] < 1) or ($HTTP_POST_VARS[$key_d] > 31) or ($HTTP_POST_VARS[$key_d] < 1) or ($HTTP_POST_VARS[$key_y] < 1)) { $message=" <center> <font class='msgf2' > ".$msg2['incorr_date_f']." ".$cat_fields[$key][0]." </font> </center> "; output_mssg_ex($message); return; } } if ($cat_fields[$key][4]=="checkbox") { $aa5=split('<option>',$cat_fields[$key][7]); $i_aa5=0; foreach ($aa5 as $value1) { $i_aa5++; $namechbx=$key.$i_aa5; if ($HTTP_POST_VARS[$namechbx]!="") {$HTTP_POST_VARS[$key]=$HTTP_POST_VARS[$key].$HTTP_POST_VARS[$namechbx]."; ";} } } $str_length1=strlen($HTTP_POST_VARS[$key]); $aa4=split(':',$cat_fields[$key][3]); $fmaxsize=$aa4[1]; if ($aa4[2]!="") $fmaxsize=$aa4[2]; $fmaxsize=2*$fmaxsize; if ( $str_length1 > $fmaxsize) { $message=" <center> <font class='msgf2' > ".$msg2['Ad_info_in_field']." <font class='msgf1' >".$cat_fields[$key][0]." </font> ".$msg2['is_too_large_inf']."</font> </center> "; output_mssg_ex($message); return; } if ($HTTP_POST_VARS[$key]==$select_text) {$HTTP_POST_VARS[$key]="";} if ($cat_fields[$key][5]=='1') { if (( $HTTP_POST_VARS[$key]=="") or ( $HTTP_POST_VARS[$key]=="http://")) { $message=" <center> <font class='msgf2' > ".$msg2['Ad_field_c']." <font class='msgf1' > ".$cat_fields[$key][0]." </font> ".$msg2['was_mising_on_form']."</font> </center> "; output_mssg_ex($message); return; } } } if ($cat_fields['email'][5]=='1'){ $HTTP_POST_VARS['email']=check_email($HTTP_POST_VARS['email']); } for ($i=1; $i<=$photos_count; $i++) { $i1=$i-1; if (file_exists($userfile[$i1])){ if (filesize($userfile[$i1]) > $phptomaxsize) { $phptomaxsize1=$phptomaxsize/1000; $message=" <center> <font class='msgf2' > ".$msg2['Your_photo_n']." $i ( ".$userfile_name[$i1]." ) ".$msg2['is_too_large_ph']." < $phptomaxsize1 ".$msg2['Kbyte_v'].". </font></font> </center> "; output_mssg_ex($message); return; } } } if ($incl_prevphoto=="yes") { $i1++; if (file_exists($userfile[$i1])){ if (filesize($userfile[$i1]) > $prviewphotomax) { $prviewphotomax1=$prviewphotomax/1000; $message=" <center> <font class='msgf2' > ".$msg2['Your_preview_photo_d']." ( ".$userfile_name[$i1]." ) ".$msg2['is_too_large_prph']." < $prviewphotomax1 ".$msg2['Kbyte_v'].". </font></font> </center> "; output_mssg_ex($message); return; } } } if ($incl_mtmdfile=="yes") { $i1++; if (file_exists($userfile[$i1])){ if (filesize($userfile[$i1]) > $mtmdfile_maxs) { $mtmdfile_maxs1=$mtmdfile_maxs/1000; $message=" <center> <font class='msgf2' > ".$msg2['Your_multimedia_file']." ".$userfile_name[$i1]." ".$msg2['is_too_large_mmf']." < $mtmdfile_maxs1 ".$msg2['Kbyte_v'].". </font></font> </center> "; output_mssg_ex($message); return; } } } } function checknusrads() { global $cat_fields, $table_ads, $ct, $page, $adsonpage, $html_header, $html_footer, $usrads_chcktime, $usrads_max, $categories,$ch_nmusr, $REMOTE_ADDR, $msg2, $msg, $templ, $indx_url; $timech1=time() - $usrads_chcktime*86400; $sql_query="select count(idnum) from $table_ads where ipaddr1='$REMOTE_ADDR' and time > $timech1"; $sql_res=mysql_query("$sql_query"); $row=mysql_fetch_row($sql_res); $count=$row[0]; if ($count >= $usrads_max) { $message=" <font class='msgf2'> <center> ".$msg2['exceeded_max_n_ads']." ($usrads_max) ".$msg2['allowed_per_time_p']." ($usrads_chcktime ".$msg2['days_v']." <p> <font class='stfnt'> <a href='{$indx_url}md=browse&ipaddr1=$REMOTE_ADDR&visunvis=1'>".$msg2['Click_here_v']." </a> ".$msg2['to_see_your_ads']." </font> </center> </font> "; $thtml= " <center><table width='400'><tr><td> <font class='stfntb'> <b><a href='$indx_url'>".$msg['top'].":</a></b></font> <font class='stfntb'> <b> <a href='{$indx_url}ct=$ct'>".$categories[$ct][0]." </b></a> </font> <hr size='1'><p> $message <p><hr size='1'> </tr></td></table> </center> "; include($templ['msg']); return; } } function check_duplication() { global $pradsdupl, $HTTP_POST_VARS, $table_ads, $msg2, $ct, $indx_url; if ($pradsdupl=='yes'){ $email_d=$HTTP_POST_VARS['email']; $title_d=$HTTP_POST_VARS['title']; $dupl_k="0"; $time1=time() - 1000; $sql_query="select idnum from $table_ads where title='$title_d' and email='$email_d' and catname='$ct' and (time > $time1)"; $sql_res=mysql_query("$sql_query"); while ($row = mysql_fetch_array ($sql_res)) { $dupl_id=$row['idnum']; $dupl_k="1"; } if ($dupl_k=="1"){ global $moderating; $title_d=stripslashes($title_d); if ($moderating!="yes"){ $ttlad1="<a href='{$indx_url}md=details&ct=$ct&id=$dupl_id'>$title_d (ID# $dupl_id)</a>"; } else {$ttlad1="<font color='#000077'>$title_d (ID# $dupl_id)</font>";} $message=" <center> <font FACE='ARIAL, HELVETICA' COLOR='#880000' > <b> ".$msg2['tried_duplicate_ad']." <br> $ttlad1 </font></b></font> </center> "; output_mssg_ex($message); return; } } } function submit_ad() { global $db_entry, $visible_val, $cat_fields, $email, $HTTP_POST_VARS, $ch_nmusr, $photo_url, $photo_path, $id_count, $userfile, $userfile_name, $visible_val, $html_header, $html_footer, $msg, $msg2, $paymgtw, $photos_url, $photos_path, $photos_count, $moderating, $ad_idnum, $sndadmnotif,$use_spmg, $templ; global $actadoptv; if($actadoptv=="yes"){$moderating="yes"; include_once("actlink.php");} global $usevrfcode; if ($usevrfcode=="yes"){include_once("vrfuncs.php"); if(!ch_vrcode()){return;}} if($paymgtw=="yes"){include("ecmc.php"); check_pmsubmit();} if ($ch_nmusr=="yes"){checknusrads();} check_fields(); ?> Many thanks again
  22. Many thanks mjdamato. All working perfectly. For now the search criteria meet my requirement, if it ever occurs that we have 2 customers with the same first name and last name will have to modify the code.
  23. That tells me nothing. What problems/errors did you experience. Besides, I specifically stated Many thanks again. when I tried to run the code, I got this: $errorMsg, when I type first name and last name and click check name nothing happens. This is how the code looks like <?php //Set values for populating form $fname = 'fname'; $lname = 'fname'; //error tracking variable $errors = array(); //Check if form was posted if($_SERVER['REQUEST_METHOD']=='POST') { //Validate input $fname = trim($_POST['fname']); $lname = trim($_POST['lname']); if(empty($fname)) { $errors[] = "First name is required."; } if(empty($lname)) { $errors[] = "Last name is required."; } //If no format errors, check if there is a match if(count($errors)) { //connect to the database $con = mysql_connect("localhost","dbusrn","db-pwd"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); $fnameSQL = mysql_real_escape_string($fname); $lnameSQL = mysql_real_escape_string($lname); $query = "SELECT * FROM Customer_Registration WHERE Firstname = '$fnameSQL' AND Lastname = '$lnameSQL'"; $result = mysql_query($query) or die(mysql_error()); if(mysql_num_rows($result)<1) { //No record found $errors[] = "No user found with the name '{$fname} {$lname}'"; } else { //Include the page to update the user. //Use the results of this query to populate the form include('update-Exist-cus.php'); exit(); } } } $errorMsg = ''; if(count($errors)) { $errorMsg .= "The following errors occured:"; $errorMsg .= "<ul>"; foreach($errors as $err) { $errorMsg .= "<li>{$err}</li>"; } $errorMsg .= "</ul>"; } ?> <html> <body> <div style="color:red;">$errorMsg</div> <form action="" method="post"> First Name: <input type="text" name="fname" value="<?php echo $fname; ?>"><br> Last Name: <input type="text" name="lname" value="<?php echo $lname; ?>"><br> <button type="submit">Check Name</button> </form> </body> </html>
×
×
  • 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.