2012-01-21 3 views
-1

누군가가 왜 그런지 설명해 주시겠습니까? 여기에 전체 코드가 있습니다.PHP와 MySQL T_CONSTANT_ENCAPSED_STRING 오류

<?php 
$country = "UNKNOWN"; 
if ($_REQUEST['id'] == "register") { 
    $name = $_POST['Name']; 
    if ($_POST['Email'] == $_POST['emailrepeat']) { 
     $email = $_POST['Email']; 
    } 
    $username = $_POST['username']; 
    if ($_POST['password'] == $_POST['PasswordAgain']) { 
     $password = $_POST['password']; 
    } 
    $address = $_POST['Address']; 
    $county = $_POST['billingState']; 
    $city = $_POST['city']; 
    $zip = $_POST['Zip']; 
    $code = rand(11212,123243132); 
    mysql_connect("extraterrestrial.x10.mx","extrater","*******"); 
    mysql_select_db("extrater_keys"); 
    $moi = "VALUES ("$name","1","0","$password","$_SERVER['REMOTE_ADDR']","0","$country","0","$county","$country","$city","$email","$zip","$address","$code")"; 
    $query = "('INSERT INTO info (name, points, isvalidated, password, ip, banned, cc, paypal, state, country, city, email, fullname, zipcode, address, code)"; } 
    mail($email, "Le Prizes Confirmation E-Mail", "Thank you for registering with us! Your confirmation link is as follows. \n http://extraterrestrial.x10.mx/confirm.php?code=" + $code + " Happy Earning!"); 
header("Location: thanks.php"); 
?> 

이것은 내 GPT 프로세스 스크립트로 사용자를 등록합니다. 그것은 나에 의해 만들어졌다.

+0

S의 완벽한 스크립트 QL 주입. – stryba

+0

감사합니다. 어떻게하면이를 고칠 수 있습니까? 보안을 강화하면 내 사이트의 관리자가 될 수 있습니다! –

답변

2
mail($email, "Le Prizes Confirmation E-Mail", "Thank you for registering with us! Your confirmation link is as follows. \n http://extraterrestrial.x10.mx/confirm.php?code=" . $code . " Happy Earning!"); 

먼저 시도해 보시고, 연결하는 대신 $code을 추가하십시오. 다른 라인 이스케이프 "에서"했고, 따라서 문자열마다 종료 되었기 때문에

또한

,

$moi = "VALUES ('$name','1','0','$password','" . $_SERVER['REMOTE_ADDR'] . "','0','$country','0','$county','$country','$city','$email','$zip','$address','$code')"; 

, 당신은 전에 한 것보다 더 나은 라인입니다.

또한 SQL 주입을 잊지 말자! 데이터베이스에 입력하기 전에 입력 내용을 살균하십시오.

+0

또한'$ moi'도 적절하게 정의되지 않았습니다. 이러한 변수는 실제로 문자열로 연결되지 않습니다. – Josh

+0

'$ moi'의 무엇이 잘못 되었습니까 –

+0

제발 편집하십시오. – Cyclone

0

$moi에 할당 할 때 (다른 것들 중에서도) 따옴표를 사용했습니다.

+0

어떻게 해결할 수 있습니까? 어떤 인용문을 제거합니까? –

+0

코드를 실제로 읽으려고 했습니까? –

+0

똑똑한 입을 필요가 없습니다 .. –

1

이 줄 :

$moi = "VALUES ("$name","1","0","$password","$_SERVER['REMOTE_ADDR']","0","$country","0","$county","$country","$city","$email","$zip","$address","$code")"; 

는 구문 분석 오류가 포함되어 있습니다. 다음과 같이 변경하십시오 :

$moi = "VALUES ('$name','1','0','$password','{$_SERVER['REMOTE_ADDR']}','0','$country','0','$county','$country','$city','$email','$zip','$address','$code')"; 

Cyclone에 언급 된 것처럼 데이터를 mysql 서버로 보내기 전에 위생적으로 처리해야합니다. 너무 mysql을 대신 mysqli를 사용하도록 고려 가능성을

http://es.php.net/manual/en/function.mysql-real-escape-string.php

를 mysql_real_escape_string를 사용하여 수행하십시오

http://es.php.net/manual/en/book.mysqli.php

· 살균이 의무는 이스케이프 문자로 작은 따옴표 '를 탈출해야하기 때문에 $ name, $ password, $ _SERVER [ 'REMOTE_ADDR'], $ country, $ county, $ city, $ email, $ zip, $ 주소 및 $ 코드