Jump to content

rahul19dj

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rahul19dj's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I tried all the types no luck ..... HELP
  2. I dont have a php compiler I just modify in notepad++
  3. How will I get this ?
  4. Yup now I have problem in something else. http://forums.phpfreaks.com/index.php?topic=363423.0 Would be helpful if you can let me know in this too
  5. I cant get to understand what am I doing wrong here. It keeps saying not a csv file . But I haved saved the file as csv file if($_FILES["file"]["type"] != "application/vnd.ms-excel"){ die("This is not a CSV file."); } elseif(is_uploaded_file($_FILES['file']['tmp_name'])){ //Connect to the database $dbhost = 'localhost'; $dbuser = 'xxxxxxxx'; $dbpass = 'xxxxxxxx'; $dbname = 'xxxxxxxx'; $link = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql server'); mysql_select_db($dbname); //Process the CSV file $handle = fopen($_FILES['file']['tmp_name'], "r"); $data = fgetcsv($handle, 1000, ";"); //Remove if CSV file does not have column headings while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $att0 = mysql_real_escape_string($data[0]); $att1 = mysql_real_escape_string($data[1]); $att2 = mysql_real_escape_string($data[2]); $att3 = mysql_real_escape_string($data[3]); $att0 = mysql_real_escape_string($data[4]); $att1 = mysql_real_escape_string($data[5]); $att2 = mysql_real_escape_string($data[6]); $att3 = mysql_real_escape_string($data[7]); $att3 = mysql_real_escape_string($data[8]); $sql = "INSERT INTO `tempusers` ( `fname` , `mobile` , `center` , `balcf` , `used` , `newbal` , `summary` , `date` , `smssend` ) VALUES ('" . $att0 . "', '" . $att1 . "', '" . $att2 . "', '" . $att3 . "', '" . $att4 . "', '" . $att5 . "', '" . $att6 . "', '" . $att7 . "', '" . $att8 . "')"; mysql_query($sql); } mysql_close($link); echo "CSV file successfully imported."; } else{ die("You shouldn't be here"); }
  6. Hey, Thanks a ton I got it finally. I just used zerofill Thanks a lot
  7. i have put unsigned but what is zero fill ( is it null )
  8. the old thread had 2 problems 1. to validate phone no ( which I got it ) 2. To add prefix of 0 before adding to the database ( which I am expecting you can help) Thanks
  9. if(empty($_POST['mobileno'])) // phone number is not empty { $error[] = 'Please enter mobile number'; } else { if(preg_match('/^\d{10}$/',$_POST['mobileno'])) // phone number is valid { $mobile = $_POST['mobileno']; // your other code here } else // phone number is not valid { $error[] = 'Phone number invalid !'; } } $prefix = 0; $pmobile = $prefix . $mobile; This is what I am trying to do for prefix. Is this right as I cant add the value 0 before the number. This is my insert statement $query_verify_mobileno = "SELECT * FROM userdtls WHERE mobileno = '$pmobile'"; $result_verify_mobileno = mysqli_query($dbc, $query_verify_mobileno); if (!$result_verify_mobileno) {//if the Query Failed ,similar to if($result_verify_mobileno==false) echo ' Database Error Occured '; } if (mysqli_num_rows($result_verify_mobileno) == 0) { // IF no previous user is using this number . // Create a unique activation code: //$activation = md5(uniqid(rand(), true)); $query_insert_user = "INSERT INTO userdtls ( mobileno, serviceprovider, pass, fname, lname, email, citystate, MUM, PUN, BNG, MYS ) VALUES ( '".$pmobile."', '".$serviceprovider."', '".$password."', '".$fname."', '".$lname."', '".$email."', '".$citystate."','".$mumbai."', '".$pune."', '".$banglore."', '".$mysore."' )";
  10. Please check the code. I want to validate mobile number of 10 digits and also add a prefix of 0 when I enter into the database. <?php include ('database_connection.php'); $citystate = $_POST['citystate']; $serviceprovider = $_POST['serviceprovider']; $accept = $_POST['accept']; if (isset($_POST['formsubmitted'])) { $error = array();//Declare An Array to store any error message if (isset($_POST['checkbox'])){ $mumbai=(in_array("mumbai",$_POST['checkbox']) ? 1 : 0); $pune=(in_array("pune",$_POST['checkbox']) ? 1 : 0); $banglore=(in_array("banglore",$_POST['checkbox']) ? 1 : 0); $mysore=(in_array("mysore",$_POST['checkbox']) ? 1 : 0); } if($mumbai+$pune+$banglore+$mysore == 0) { $error[] ='Please check atleast one SMS center'; } if($accept != 1) { $error[] = 'Please check terms '; } # Get the phone number from somewhere if (empty($_POST['mobileno'])) {//if no name has been supplied $error[] = 'Please Enter a Mobile Number ';//add to array "error" } if (empty($_POST['mobileno'])) {//if no name has been supplied $error[] = 'Please Enter a Mobile Number ';//add to array "error" } else { $mobile = $_POST['mobileno'];//else assign it a variable /*if( preg_match("^[0-9]{10}", $mobile) ){ } else { $error[] = 'Your Mobile No is invalid '; } */ } if (empty($_POST['fname'])) {//if no name has been supplied $error[] = 'Please Enter a First name ';//add to array "error" } else { $fname = $_POST['fname'];//else assign it a variable } if (empty($_POST['lname'])) {//if no name has been supplied $error[] = 'Please Enter a Last name ';//add to array "error" } else { $lname = $_POST['lname'];//else assign it a variable } if (empty($_POST['email'])) { $error[] = 'Please Enter your Email '; } else { if (preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $_POST['email'])) { //regular expression for email validation $email = $_POST['email']; } else { $error[] = 'Your EMail Address is invalid '; } } if (empty($_POST['passwd1'])) { $error[] = 'Please Enter Your Password '; } else { $password = $_POST['passwd1']; } if (empty($_POST['passwd2'])) { $error[] = 'Please Verify Your Password '; } else { $password = $_POST['passwd2']; } if($_POST["passwd1"]!=$_POST["passwd2"]) { $error[] = 'Password does not match'; } if (empty($error)) //send to Database if there's no error ' { //If everything's OK... // Make sure the mobile no is available: $query_verify_mobileno = "SELECT * FROM userdtls WHERE mobileno = '$mobile'"; $result_verify_mobileno = mysqli_query($dbc, $query_verify_mobileno); if (!$result_verify_mobileno) {//if the Query Failed ,similar to if($result_verify_mobileno==false) echo ' Database Error Occured '; } if (mysqli_num_rows($result_verify_mobileno) == 0) { // IF no previous user is using this number . // Create a unique activation code: //$activation = md5(uniqid(rand(), true)); $query_insert_user = "INSERT INTO userdtls ( mobileno, serviceprovider, pass, fname, lname, email, citystate, MUM, PUN, BNG, MYS ) VALUES ( '".$mobile."', '".$serviceprovider."', '".$password."', '".$fname."', '".$lname."', '".$email."', '".$citystate."','".$mumbai."', '".$pune."', '".$banglore."', '".$mysore."' )";
  11. hey i solved tht problem thanks a tonn for your help
  12. hey how do I add a prefix to the mobileno and also limit them only for 10 digit and give error if more than 10 digit
×
×
  • 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.