سلام
جناب شاهپیری عزیز کد های شما هست که گفتید بزاریم تو هاست !!!
فقط پسورد ویوزر نیم دیتابیس رو من دادم بهش و کامل سمپل شما رو اجرا کردم
اشکالش کجاس؟
<?
$databasehost = "";
$databasename = "";
$databaseusername ="";
$databasepassword = "";
$con = mysqli_connect($databasehost,$databaseusername,$databasepassword) or die(mysqli_error($con));
mysqli_select_db($con,$databasename) or die(mysqli_error($con));
mysqli_query($con,"SET CHARACTER SET utf8");
$username=$_GET['username'];
$query = "SELECT username,useremail,profilurl FROM `tbluser` WHERE `username` ='".$username."'";
$sth = mysqli_query($con,$query);
if (mysqli_errno($con)) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysqli_error($con);
}
else
{
$rows = array();
while($r = mysqli_fetch_assoc($sth)) {
$rows[] = $r;
}
mysqli_close($con);
print json_encode(array("result"=>$rows),JSON_UNESCAPED_SLASHES);
}
?>
و
این
<?php
$databasehost = "";
$databasename = "";
$databaseusername ="";
$databasepassword = "";
$email ='';
$username ='';
$pass ='';
// Path to move uploaded files
$target_path = "uploaded/";
// array for final json respone
$response = array();
$file_upload_url='';
// getting server ip address
$server_ip =$_SERVER['SERVER_NAME'];
$scriptname=$_SERVER['SCRIPT_NAME'];
$scriptpatch=substr($scriptname, 0, -12);
// final file url that is being uploaded
$con = mysqli_connect($databasehost,$databaseusername,$databasepassword) or die(mysqli_error($con));
mysqli_select_db($con,$databasename) or die(mysqli_error($con));
mysqli_query($con,"SET CHARACTER SET utf8");
if($_SERVER['REQUEST_METHOD']=='POST'){
$email = isset($_POST['email']) ? $_POST['email'] : '';
$username = isset($_POST['username']) ? $_POST['username'] : '';
$pass = isset($_POST['pass']) ? $_POST['pass'] : '';
if( $email == ''|| $username == ''||$pass==''){
$response['error'] = true;
$response['message'] = 'fill all variable';
}else{
if (isset($_FILES['image']['name'])) {
$target_path = $target_path . basename($_FILES['image']['name']);
try {
// Throws exception incase file is not being moved
if (!move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
// make error flag true
$response['error'] = true;
$response['message'] = 'Could not move the file!';
}
$file_upload_url = 'http://' . $server_ip .$scriptpatch. $target_path;
} catch (Exception $e) {
// Exception occurred. Make error flag true
$response['error'] = true;
$response['message'] = $e->getMessage();
}
}
$sql = "INSERT INTO `tbluser` (username,userpass,useremail,profilurl) VALUES(' $username','$pass','$email',' $file_upload_url')";
if(mysqli_query($con,$sql)){
//اگه موقیت آمیز بود
$response['username'] = $username;
$response['error'] = false;
}else{
//اگه نبود
$response['error'] = true;
$response['message'] = 'failed to connect to db';
}
//Closing the database connection
mysqli_close($con);
}
}else{
$response['error'] = true;
$response['message'] = 'method not post';
}
echo json_encode($response);
?>
New folder.rar