what is the problem in my code

<?php

class mysql{
	
	private $localhost="*****";
	private $db_users="*****";
	private $db_password="*****";
	private $db_name="*****";

	function __construct(){
		
	mysql_connect($this->localhost,$this->db_users,$this->db_password);
	mysql_select_db($this->db_name);
	
	}
	
	function sql(){
		
		if ($_POST['submit']){
			
				
			$user_name=$_POST['us_name'];
			$co_name=$_POST['co_name'];
			$co_email=$_POST['co_email'];
			$co_mobile=$_POST['co_mobile'];
			$country_code=$_POST['country_code'];
			$city=$_POST['city'];
			$Designation=$_POST['Designation'];
			$co_web=$_POST['co_web'];
			$co_Landline=$_POST['co_Landline'];
			$CompanyType=$_POST['CompanyType'];
			$no_of_employees=$_POST['no_of_employees'];
			$Address=$_POST['Address'];
			$IATA=$_POST['IATA'];
			$TAAI=$_POST['TAAI'];
			$TAFI=$_POST['TAFI'];
			$IATO=$_POST['IATO'];
			$ADTOI=$_POST['ADTOI'];
			$ASTA=$_POST['ASTA'];
			$PATA=$_POST['PATA'];
			$OTOAI=$_POST['OTOAI'];
			
			if (empty($user_name) && empty($co_name) && empty($co_email) && empty($co_mobile)){
				
				echo "<script type='text/javascript'> alert('please insert data to proceed')</script>";
			}
			else{
				
			
				$test="SELECT * FROM users WHERE co_email='$co_email '";
				
				$result=mysql_query($test);
				
				if($result){
					
					echo "<script type='text/javascript'> alert('please insert valid email')</script>";
				}
				else{
					
				
				
					/// validate vars
								
					$filter_user_name=filter_var($user_name, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
					$filter_co_name=filter_var($co_name, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
					$co_email=$_POST['co_email'];
					$co_mobile=$_POST['co_mobile'];
					$country_code=$_POST['country_code'];
					$filter_city=filter_var($city, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
					$filter_Designation=filter_var($Designation, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
					$co_web=$_POST['co_web'];
					$co_Landline=$_POST['co_Landline'];
					$CompanyType=$_POST['CompanyType'];
					$no_of_employees=$_POST['no_of_employees'];
					$filter_Address=filter_var($Address, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
					$IATA=$_POST['IATA'];
					$TAAI=$_POST['TAAI'];
					$TAFI=$_POST['TAFI'];
					$IATO=$_POST['IATO'];
					$ADTOI=$_POST['ADTOI'];
					$ASTA=$_POST['ASTA'];
					$PATA=$_POST['PATA'];
					$OTOAI=$_POST['OTOAI'];			
								
					/// save all in database.
					$sql="INSERT INTO users(user_name,co_name,co_email,co_mobile,country_code,city,Designation,co_web,co_Landline,CompanyType,no_of_employees,Address,IATA,TAAI,TAFI,IATO,ADTOI,ASTA,PATA,OTOAI) VALUES('$filter_user_name','$filter_co_name','$co_email','$co_mobile','$country_code','$filter_city','$filter_Designation','$co_web','$co_Landline','$CompanyType','$no_of_employees','$filter_Address','$IATA','$TAAI','$TAFI','$IATO','$ADTOI','$ASTA','$PATA','$OTOAI')";

					$result=mysql_query($sql);
						if (!$result) {
							echo "<script type='text/javascript'> alert('Query: {$sql} failed with ' . mysql_error($connect)')</script>";
						}
						else {								
									   
							$to = "$co_email";
							$subject = "*******";
							$txt = "set your password by this link :  http://*************/setpassword.php";
							$headers = "From: admin@egitto.com.eg." . "\r\n" . 
							"CC: ***********@yahoo.com";								
                                                         mail($to,$subject,$txt,$headers);
									
							echo "<script type='text/javascript'>alert('saved successfully...')</script>";
										
						}
				}
			}
		}
	}	
}	
$use=new mysql;
$use->sql();

?>

Open in new window



when make refresh msg appears
AHMED SAMYownerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gr8gonzoConsultantCommented:
What's the error message?
0
AHMED SAMYownerAuthor Commented:
echo "<script type='text/javascript'> alert('please insert data to proceed')</script>";
0
Julian HansenCommented:
You are still on mysql - this is a deprecated library you should udpate your code to use MySQLI or PDO (MySQLi is the easiest as it is very similar to MySQL).

It is not clear what your problem is - do you get
- an error if so what is it
- an unexpected result if so what is it
- no result
- wrong result

The more information you can give us the easier (and quicker) we can help you.

BTW you should probably reconsider your echo "<script> ... </script>" error messages - this is not good structure. Rather return a status that indicates what message should be sent to the user and handle that in one place.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AHMED SAMYownerAuthor Commented:
forget i changed code and it is working right now

thanks all
0
AHMED SAMYownerAuthor Commented:
hello
Expert Comment

i changed to godaddy host for my client
it support php up to 5.6
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.