473,379 Members | 1,255 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

How to allow Candadian Zipcodes in SQL Table

Topbidder
I am trying to create a table to allow Canadian Postal Codes as of now the site only takes Zip Codes and that limits the site to only allow people from the United States to register would anyone know the sql i would add to the database to allow Canadian postal codes to register or the table i would use to create it in phpmyadmin

Thank you SO much
Jul 9 '10 #1

✓ answered by JKing

Expand|Select|Wrap|Line Numbers
  1. <td class="memberlogin">Zipcode&nbsp;</td>
  2.                                 <td  class="contact">:&nbsp;&nbsp;</td>
  3.                                 <td align="left"><input name="zipcode" type="text" value=""  class="input_120" onChange="isNum(this)"></td>
  4.  
That HTML is where the javascript function is called.
You could remove the onChange. You would still need to perform some validation on this field whether it be client or server side.

9 1707
Niheel
2,460 Expert Mod 2GB
Depends on your application and your database schema. If it's just the application code that restricts certain type of zipcodes, then you can change that in the Code.

Most likely than not, you won't have to change your database. Just edit the application code to allow ZipCodes from other countries.
Jul 9 '10 #2
this is the site http://top-bidder.com it is the swoopo but in the general setting i cant find anywhere and when i looked through the DB i didnt see anywhere in there either where to add or change it to canadian postal codes is there a sql i can add to just allow them if you go there and register you will see what i mean it wont take anything other than Zip Codes says to enter a numeric value
Jul 9 '10 #3
Niheel
2,460 Expert Mod 2GB
It's not in the SQL, it's your website's code. The code validates the USER input that is then placed into the database.

You'll need to either change your code yourself or hire a developer to do it for you.
Jul 9 '10 #4
i found where it says postal code in register.php is this b where i would change the code and if so please let me know what to change it too thank you

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //============================= SUBMIT REGISTRATION INFO======================================
  3.  
  4.  
  5. if($error==1)
  6.     $msg=$lang['username_already_exist'];
  7. if($error==2)
  8.     $msg=$lang['email_already_exist'];
  9. if($error==3)
  10.     $msg=$lang['all_already_exist'];
  11.     //$msg=$lang['mobile_already_exist'];
  12.  
  13. if($user)
  14.     {
  15.  
  16.     /*
  17.     $Sel_Result=$dbh->query("select * from users where username='$login' and deleted='N'"); 
  18.     if(@mysql_num_rows($Sel_Result)==0)    
  19.     {
  20.     $Sel_Result1=$dbh->query("select * from users where email='$email' and username='$login' and deleted='N'"); 
  21.     if(@mysql_num_rows($Sel_Result1)==0)
  22.     {
  23.     */
  24.  
  25.     $Sel_Result2=$dbh->query("select * from users where mobile='$mobile' and email='$email' and username='$user' and deleted='N'"); 
  26.     if(@mysql_num_rows($Sel_Result2)==0)
  27.     {
  28.  
  29.  
  30.     $Dob=$Date_Year."-".$Date_Month."-".$Date_Day;
  31.  
  32.      $sql11=$dbh->query("insert into users (username ,password ,fname ,lname ,email ,sex,city ,postcode ,country ,phone ,mobile ,entrydate, address, network, tell_friend, balance, family_name,user_type) values('$user' ,'$pass' ,'$name' ,'$lname' ,'$email' ,'$sex','$city' ,'$zipcode' ,'$id_country','$phone','$mobile' ,'".$CURRENT_Time."','$address', '$network', '$friendemail','$Signing_up','$family_name','normal')");
  33.  
  34.     $reg_id=mysql_insert_id();
  35.     $dbh->query("insert into amount_transfer (user_id, entrydate, amount, pay_type, reason,credit_type,amount_type) values('$reg_id', '$CURRENT_Time', '$Signing_up', 'Credit', 'Welcome Coupon','C','R')");
  36.  
  37.     $sql12=$dbh->query("insert into my_setting (user_id, newsletter ,auction_bid ,auction_result ,new_auction) values ('$reg_id' ,'$newsletter' ,'$auction_bid' ,'$auction_result' ,'$new_auction')");
  38.  
  39.     if($friendemail!='')
  40.     {
  41.         $dbh->query("insert into amount_transfer (user_id, entrydate, amount, pay_type, reason,credit_type,amount_type) values('$friendemail', '$CURRENT_Time', '$Friend_Bid', 'Credit', 'Tell a friend - Bid','C','T')");
  42.  
  43.          $sql2="update users set balance=balance+'$Friend_Bid' where user_id='$friendemail'";
  44.          $result=$dbh->query($sql2);
  45.     }
  46.     //$Res=$dbh->query("select user_id from users where id order by user_id desc ");
  47.     //$Data=@mysql_fetch_object($Res);        
  48.  
  49.             //$subject=$lang['register_subject'];
  50.             $Link='<a href="'.$SITE_URL.'/index.php?show=active&user_id='.md5($reg_id).'">'.$lang['here'].'</a>';
  51.  
  52.             $Email_info=$functions->Email_info(1);
  53.             $subject=$Email_info['subject'];
  54.              $msgBody1=$Email_info["message"];
  55.  
  56.              $msgBody=str_replace("\\", "", $msgBody1);
  57.             eval("\$msgBody = \"$msgBody\";");
  58.  
  59.             //$Message=$lang['register_mail'];
  60.             //eval("\$Message = \"$Message\";");
  61.  
  62.     $functions->Send_mail($SITE_EMAIL,$SITE_TITLE,$email,$subject,$msgBody);    
  63.     echo '<script>document.location="index.php?show=success";</script>';
  64.  
  65.  
  66.     }
  67.     else
  68.         echo '<script>document.location="index.php?show=register&error=3";</script>';
  69.  
  70.     /*
  71.     }
  72.     else
  73.         echo '<script>document.location="index.php?show=register&error=2";</script>';
  74.     }
  75.     else
  76.         echo '<script>document.location="index.php?show=register&error=1";</script>';
  77.     */
  78.  
  79.     }
  80. //==============================DISPAY LOCATION DROP DOWN ====================================
  81.  
  82. $Country_dropdown=$functions->Get_Country($Default_country);
  83. if($freind_id)
  84. {
  85.     $friend_email=$functions->Get_Friend_Email($freind_id);
  86.     $friend_list='<tr>
  87.                                 <td class="contact">
  88.                                 '.$lang['tell_frnd'].'&nbsp;&nbsp;&nbsp;</td>
  89.                                 <td>:<font color="#FF0000">*</font>&nbsp;&nbsp;</td>
  90.                             <td align="left">'.$friend_email.'</td>
  91.                           </tr>';    
  92. }
  93.  
  94. $Sex_Drop_Down='<select name="sex">
  95.                         <option value="M">'.$lang['male'].'</option>
  96.                         <option value="F">'.$lang['female'].'</option>
  97.                       </select>';    
  98.  
  99. $Month_dropdown=$functions->Get_month('');
  100. $Day_dropdown=$functions->Get_day('');
  101. $Year_dropdown=$functions->Get_Year('');    
  102.  
  103.  
  104. ?>
Jul 9 '10 #5
Atli
5,058 Expert 4TB
I don't get it. The site doesn't seem to validate the zip code or restrict it to valid US zip code values.

Could you not simply rename the zip code field to something like Zip/Postal code and just use that for both? Or just update the label based on the selection? (Using JavaScript)
Jul 10 '10 #6
JKing
1,206 Expert 1GB
There is javascript on the page that validates the zip field allowing only numbers.

This is the javascript function
Expand|Select|Wrap|Line Numbers
  1. function isNum(val) {
  2.  
  3.    if (val.value.length != 0) {
  4.  
  5.       for (i = 0; i < val.value.length; i++) 
  6.       {
  7.          var ch = val.value.charAt(i);
  8.  
  9.          if (ch >= "0" && ch <= "9") 
  10.           continue;
  11.           else 
  12.               {
  13.                 alert(document.getElementById('Num_value').innerHTML+"\n");
  14.                 val.value = "";
  15.                  val.focus();
  16.  
  17.             false;
  18.               }
  19.           }
  20.        }
  21.    return true;
  22.  
References this html for the alert.
Expand|Select|Wrap|Line Numbers
  1. <div id="Num_value" style="display:none;">Please enter Numeric value</div> 
  2.  
Jul 10 '10 #7
Expand|Select|Wrap|Line Numbers
  1.    1. <div id="Num_value" style="display:none;">Please enter Numeric value</div> 
  2.    2.  
so can i edit this to allow character as well as numeric so it takes both postal/zip codes
Jul 10 '10 #8
JKing
1,206 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. <td class="memberlogin">Zipcode&nbsp;</td>
  2.                                 <td  class="contact">:&nbsp;&nbsp;</td>
  3.                                 <td align="left"><input name="zipcode" type="text" value=""  class="input_120" onChange="isNum(this)"></td>
  4.  
That HTML is where the javascript function is called.
You could remove the onChange. You would still need to perform some validation on this field whether it be client or server side.
Jul 10 '10 #9
Thank you all so much i am just learning so i am very grateful for all your help and learning all new things is awesome
Jul 10 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: JJA | last post by:
I need to show data for the top 3 zipcodes for EACH of the top 5 counties. I feel totally blocked on how to make this work properly. Here is my code - anything you can suggest will be greatly...
0
by: Justin Tocci | last post by:
I've found the pg_depend table, but it doesn't appear to include this info. (Or am I missing it?) I'm looking to get all view names that I need to drop to allow a particular table to DROP...
5
by: Bob | last post by:
I have a form with controls City and Zip Code, and a Table containing Zip Code with the corresponding City. I would like the user to just enter Zip Code, either by typing or with a combo box; then...
6
by: Don Sealer | last post by:
Can you tell me how many fields Access will allow in a table. As I stated in a previous post, I need to track multiple measurements from machines 10 per day. In some cases this will give me 120...
0
by: tasmisr | last post by:
Hi, I have a database of zipcodes,longitude and latitude. I want to calculate the nearby zipcodes from a specific zipcode. I have the function that gives the distance between two zipcodes but I...
1
by: No bother | last post by:
If I have a procedure that will be run simultaneously by several people which requires the use of a temporary table is there a way for the table to be accessible only in the instance in which the...
4
by: Thomadh | last post by:
I have only updated 1 table with a Form to date Can you update more than 1 table from a single Form input? The Wizard seems to allow only 1 Table to be selected as the data source If so any quick...
1
by: Robert | last post by:
Hello, I need a query where I can give a beginning zipcode and ending zipcode. These zipcodes include some with zip+4. I know to use the between function. Please help. Robert
1
by: hedda | last post by:
I need to link to our database at work and update our customer shipping information (16,000 customers). I have a list of zipcodes (570) I only want to pull customers with or without the zipcodes...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.