PHP - Telephone Field Format Needs Changing
Hi guys, first and foremost I’m not a programmer, but I do have a little problem that I need help with. I have a website and there is a members registration form, within this form there is a Telephone field.
The telephone field requires a certain format e.g. 138 xxxxxxxxx, I would like your help on how to change the format, so that I can input random numbers.
where and how should I be editing this field to achieve the required result?
Thanks in advance.
Similar TutorialsI have a db with db with date and the format for the date is 1975-12-22 and I want them to appear as 1975-DEC-22 I don't mind changing the date from date to varchar to make this happen maybe pulling each record and using find and replace or something. What would be the best way to make this happen. thanks in advance. Hey, I have a database with a date field that has the date in this format: August 2, 2010 11:04 pm I was wondering if it was possible to change this so I have the day, month and year in separate variables like this: $day = "2"; $month = "8"; $year = "2010"; Also notice how I have changed August to "8". I was wondering if there was an easy way around getting this done? Thanks in advance Hi, I have a date string being output from a database into a variable $date which looks like: Code: [Select] $date = "2010-09-30 12:45:52"; I'm trying to change the format to: 30 September 2010 (I want to get rid of the time also) Does anyone know how I could do this in PHP? Any help would be much appreciated! Hi
I have a javascript calendar that populates a form field (survey) in the format of dd/mm/yyyy. I don't know of a method to change the format in the calendar.
So, I would like the format to be changed at the point the form is submitted and the date is used to update a record.
I have tried to amend the portion of the update script for the survey field to change the format as part of it submitting the change. I used this line:
GetSQLValueString(date("Y-m-d, strtotime("$_POST['survey']), "text")
but I'm not getting the expected results, essentially from the text field entry format of dd/mm/yyyy I want Y-m-d
Is this possible?
Thanks in advance.
How to change the date in format of ISO-8601 (example: 2005-08-15T15:52:01+0000) to RFC 822 (example: Mon, 15 Aug 05 15:52:01 +0000)? Hi, I have a date and time stored in a database field (publishdate) and I'm using php to fetch it and display it in an HTML table. Only problem is it shows up in epoch time. I can't get it to display in human readable time for some reason. Here's the code I'm using (it's automatically generated by some software) // View column for publishdate field $column = new TextViewColumn('publishdate', 'Publishdate', $this->dataset); $column->SetOrderable(true); Many thanks in advance. Tony I have a simple mysql database holding information about an image upload including its 'name' and 'date uploaded' [current_timestamp()] to a folder 'image' I then display it into a table using the php ‘foreach’ facility. I want the date to be displayed in the ‘dd/mm/yyyy’ format. not the default yyyy/mm/dd. Here is the relevant code <?php $conn = mysqli_connect("localhost", "root", "", "dbname"); $results = mysqli_query($conn, "SELECT * FROM tablename"); $image = mysqli_fetch_all($results, MYSQLI_ASSOC); ?> <?php foreach ($image as $user): ?> <td><p>NAME</p><?php echo $user['name']; ?></td> <td><p>COMMENT</p><?php echo $user['comment']; ?></td> <td><p>DATE</p><?php echo $user['date']; ?></td> What do I need to do? THANKS- Warren Alright, I looked though the read me's, went over the FAQ's... Think it is time to post...
So, this lump is what I got from going though google and piecing together the bits that looked good.
<?php $db_host = "****"; $db_user = "****"; $db_pwd = "****"; $database = "****"; $table = "****"; $query = "SELECT * FROM {$table}"; $conn = mysqli_connect($db_host, $db_user, $db_pwd, $database); $result = mysqli_query($conn,$query) or trigger_error($query . ' - has encountered an error at:<br />' . mysqli_error($conn)); $fields = mysqli_fetch_fields($conn); $field_count = mysqli_num_fields($conn); echo '<table border="1" style="width:100%">' . "\n" . '<tr>'; $i = 0; foreach($fields as $field) { if(++$i == 1) { echo '<th colspan="' . $field_count . '">' . $field->table . '</th></tr><tr>'; } echo "\n" . '<th>' . $field->name . '</th>'; } echo '</tr>'; while($row = mysqli_fetch_row($result)) { echo '<tr><td>' . implode('</td><td>' , $row) . '</td></tr>'; } echo '</table>'; ?>The goal is to display the table and conditionally format the contents. Let's forget about the conditional part (thinking if/than but don't know how I'm going to do that yet) and focus on the key problem: displaying the table. I have tested this code. It works...to a point. it displays the table and its contents but no headers. I know my issue is in line 20 and 22 but I can not for the life of me figure it out. If it is stupidly easy (for you) please remember that I am not a coder. At best I am a scripter when it comes to linux. I am over my head on this stuff. Thank you all for any help you can give me Edited by TheAlmightyOS, 18 November 2014 - 03:30 PM. Hi there, I was wondering if it was possible to change a forms action field with PHP. Basically, if there are several checkboxes for the user to select and a specific checkbox was selected, how would I redirect users to an alternative webpage on submit? I've been playing around with several methods, and one of them was: Code: [Select] <?php if(isset($_POST['Example']) && $_POST['Example'] == 'FormValueGoesHere') { echo ('./page1.php'); } else { echo ('./page2.php'); } ?> But the form action would only display page1.php even with nothing selected. Maybe I'm just being stupid because it's getting late, but I'd appreciate any assistance. Thanks Hi, I have a script that dumps the information from one of my MySQL tables into a CSV. The script works great, but in the result, the names of the MySQL columns are shown as-is. In other words, I have a column named "field4" that shows up as "field4" in the CSV. How can I modify the columns to more descriptive names without modifying the database itself? Here's my code: Code: [Select] <?php $host = "*********"; $user = "*********"; $pass = "*********"; $db = "database_name"; $table = "table"; $file = "member_information"; $link = mysql_connect($host, $user, $pass) or die("Cannot connect." . mysql_error()); mysql_select_db($db) or die("Cannot connect."); $result = mysql_query("SHOW COLUMNS FROM ".$table.""); $i = 0; if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $csv_output .= $row['Field'].","; $i++;} } $csv_output .= "\n"; $values = mysql_query("SELECT * FROM ".$table.""); while ($rowr = mysql_fetch_row($values)) { for ($j=0;$j<$i;$j++) { $csv_output .= $rowr[$j].", "; } $csv_output .= "\n"; } $filename = $file."_".date("m.d.y"); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("m.d.y") . ".csv"); header( "Content-disposition: filename=".$filename.".csv"); print $csv_output; exit; ?> The CSV it spits out looks like this: Code: [Select] field1 field2 field3 field 4 info info info info I want it to look like this: Code: [Select] Name Email Location Age info info info info Thanks in advance! Can anyone tell me why this bit of coding isn't working. I want a a form to validate the telephone number for the UK and been having a bash around with various ways to code this, with no success so far. I started with FILTER_VALIDATE_INT, but found out that "0" wouldnt be taken so I added FILTER_FLAG_ALLOW_OCTAL. But then it seems that the spaces, dashes wouldn't be taken as well as a limit on 10 characters occured. So I tried to write myself a small function that used an array to validate the styles etc... But this seemed to allow any string character. So I moved on to preg_match, but I can't seem toget my coding to work. It's driving me mad now, probably just need a break But any help will be much appericated! [ if (!empty($_SESSION['add_customer_form'] ["telephone_no"])) { //if (!is_numeric($number)) //if(!filter_var($int, )) $number = $_POST["telephone_no"]; if(!preg_match("/^(+)?(([0-9]+)-?s?)*([0-9]+-[0-9]+)*([0-9]+)*$/", trim($number))) { $_SESSION['add_customer_errors']["telephone_no"] = ("$number Sorry, but you′ve entered an incorrect fromat"); } //if( !preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $_SESSION['add_customer_errors']["telephone_no"]) ) //{ /// $number = $_POST["telephone_no"]; //$_SESSION['add_customer_errors']["telephone_no"] = ("$number Sorry, but you′ve entered an incorrect fromat"); //} } ] Hi, I have a number (int) stored in the database in this case a uk Telephone Number, its stored as like 01616276576 what i want to be able to do is pull it out of db and split it into chucks like 0161 627 6576 how can i do this? Code: [Select] <?php "INSERT INTO costumers (firstname,lastname,birthdate,product_name,price,details,category,subcategory,city,state,zipcode,country) VALUES('$fname','$lname','$birthday','$itemname','$price','$details','$category','$subcategory','$city','$state','$zipcode','$country')"; ?> What am I missing in the INSERT query above that is not inserting the values of birthday.? Is there a recommended BEST PRACTICE for storing (and retrieving) telephone numbers from a database table? Is it best to store (in the USA) the area code separate from the rest of the number? Remove parenthesis and/or dashes? Or is there no reason to concern myself with performance or hacking issues regarding the storage of phone numbers as 323-555-1212 or (323)555-1212 inside my table?
Hello All, function convertTimeFormat($time12Hour) { // Initialized required variable to an empty string. $time24Hour = ""; // Used explode() function to break the string into an array and stored its value in $Split variable. $Split = explode(":",$time12Hour); // print_r(explode (":", $time12Hour)); => Array ( [0] => 09 [1] => 50 [2] => 08AM ) // Retrieved only "hour" from the array and stored in $Hour variable. $Hour = $Split[0]; $Split[2] = substr($Split[2],0,2); // Used stripos() function to find the position of the first occurrence of a string inside another string. if($Hour == '12' && strpos($time12Hour,"AM")!== FALSE) { // Code here } elseif(strpos($time12Hour,"PM")!== FALSE && $Hour != "12") { // code here } return $time24Hour; } $time12Hour = "09:50:08AM"; $result = convertTimeFormat($time12Hour); print_r($result); /* Input : "09:50:08AM"; Output : "21:50:08PM"; */
Hi all, I am currently making a website that has e-custom functions and a back end for the client. I want them to be able to upload images - but they need to be transparent. I do not want to leave this in the hands of the client, so I am looking at ways of using the GD library to make the change I got no issue with the png/gif type for upload/resize function since this type already transparent background but my major problems is how to deal with jpeg/jpg image type which is their background was not a transparent...so is it possible I can change/ convert to png/gif type upon successful of uploading image...so the new final image will be png/gif type with transparent background...is it doable...I am not even sure it is possible...? Thanks for any help.. This is my first real jump into PHP, I created a small script a few years ago but have not touched it since (or any other programming for that matter), so I'm not sure how to start this. I need a script that I can run once a day through cron and take the date from one table/filed and insert it into a different table/field, converting the human readable date to a Unix date. Table Name: Ads Field: endtime_value (human readable date) to Table Name: Node Field: auto_expire (Converted to Unix time) Both use a field named "nid" as the key field, so the fields should match each nid field from one table to the next. Following a tutorial I have been able to insert into a field certain data, but I don't know how to do it so the nid's match and how to convert the human readable date to Unix time. Thanks in advance!. Hi: I'm going crazy trying to do the following: I'm making a job registration process where the user registers on one php page to the website, must acknowlege and email receipt using an activate php page, then is directed to upload their C.V. (resume) based on the email address they enter in the active page output. I then run an upload page to store the resume in teh MySQL db based on the users email address in the same record. If I isolate the process of the user registering to the db, it works perfectly. If I isolate the file upload process into the db, it works perfect. I simply cannot upload teh file to the existing record based on teh email form field matching the user_email field in the db. With the processes together, teh user is activated, but teh file is not uploaded. Maybe I've simply been at this too long today, but am compeled to get through it by end day. If anyone can help sugest a better way or help me fix this, I will soo greatly appreciate it. My code is as follows for the 2 pages. ---------activate.php------- <?php session_start(); include ('reg_dbc.php'); if (!isset($_GET['usr']) && !isset($_GET['code']) ) { $msg = "ERROR: The code does not match.."; exit(); } $rsCode = mysql_query("SELECT activation_code from subscribers where user_email='$_GET[usr]'") or die(mysql_error()); list($acode) = mysql_fetch_array($rsCode); if ($_GET['code'] == $acode) { mysql_query("update subscribers set user_activated=1 where user_email='$_GET[usr]'") or die(mysql_error()); echo "<h3><center>Thank You! This is step 2 of 3. </h3>Your email is confirmed. Please upload your C.V. now to complete step 3.</center>"; } else { echo "ERROR: Incorrect activation code... not valid"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Job application activation</title> </head> <body> <center> <br/><br/><br/> <p align="center"> <form name="form1" method="post" action="upload.php" style="padding:5px;"> <p>Re-enter you Email : <input name="email" type="text" id="email"/></p></form> <form enctype="multipart/form-data" action="upload.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="4000000"> Upload your C.V.: <input name="userfile" type="file" id="userfile"> <input name="upload" type="submit" id="upload" value="Upload your C.V."/></form> </p> </center> </body> </html> --------upload.php---------- <?php session_start(); if (!isset($_GET['usr']) && !isset($_GET['code']) ) { $msg = "ERROR: The code does not match.."; exit(); } if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $email = $_POST['email']['user_email']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } include 'reg_dbc.php'; $query = "UPDATE subscribers WHERE $email = user_email (name, size, type, content ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$content')"; mysql_query($query) or die('Error, query failed'); mysql_close($dbname); } ?> <center> <br/> <br/> <br/> <br/> Thank you for uploading your <?php echo "$fileName"; ?> file, completing your registration, and providing us your C.V. for this position. <br/> <br/> <br/> We will contact you if your canditature qualifies. </center> Code: [Select] $new_array2=array_diff($my_array,$itemIds); $updatedb = mysql_query("UPDATE content_type_ads SET field_expire_value = '666' WHERE $new_array2 = field_item_id_value"); "$new_array2" has only 12 digit numbers for each item in the array, and I want to match them to the "field_item_id_value" field in the table, updating the "field_expire_value" field for the record where they match. I know I am close because the UPDATE code works before I add the WHERE statement (it of course adds '666' to EVERY field, but for a noobie it's a start!). |