php推荐系统错误

时间:2018-05-30 20:21:40

标签: php referrals

好的,所以我正致力于使用Here

中使用的源代码创建推荐系统

现在我安装了所有内容,但只更改了$con to $db的sql连接 到目前为止,每当我创建一个URL,并尝试访问该链接 我得到一个错误的getway错误: 例如:Cr enter image description here

用我的php代码创建不包括数据库连接。

if(isset($_POST['create-ref']))
{

$user=mysqli_real_escape_string($db,$_POST["user"]);
$user=htmlentities($user);

//friendly URL conversion
function to_prety_url($str){
    if($str !== mb_convert_encoding( mb_convert_encoding($str, 'UTF-32', 'UTF-8'), 'UTF-8', 'UTF-32') )
        $str = mb_convert_encoding($str, 'UTF-8', mb_detect_encoding($str));
    $str = htmlentities($str, ENT_NOQUOTES, 'UTF-8');
    $str = preg_replace('`&([a-z]{1,2})(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig);`i', '\1', $str);
    $str = html_entity_decode($str, ENT_NOQUOTES, 'UTF-8');
    $str = preg_replace(array('`[^a-z0-9]`i','`[-]+`'), '-', $str);
    $str = strtolower( trim($str, '-') );
    return $str;
}
$str=to_prety_url($user);

// sql query for inserting data into database
$sql_query = "INSERT INTO referral (user,str) VALUES ('$user','$str')";
$result_set=mysqli_query($db,$sql_query);

//Referral URL
$refurl="http://Mywebsite.com/refer/$str";  //replace it with your URL ex: http://example.com/refer/$str

}

?>

更新注意这不是上面示例图片中显示的相同用户,这只是在我的数据库中显示出来的** 从那里,它确实保存到我的数据库中,如 - enter image description here

现在对于表单本身,代码看起来像

<form method="post" class="form-horizontal" data-parsley-validate>
<div class="form-group">
<input type="text" class="form-control" name="user" placeholder="User Name" data-parsley-required="true" maxlength="25">
 </div>
<div class="form-group">
<button type="submit" name="create-ref" class="btn btn-success btn-block btn-lg">Create Now</button>
</div>
<br />

<?php
if(isset($_POST['user'])) {
echo "<div class='alert alert-success'><p class='inmt no-margin text-center'><i class='fa fa-thumbs-up'></i> Referral URL Created</p><br /><p><pre>$refurl</pre></p></div>";
}
?>

<br />
<a href="admin-panel.php" class="btn btn-success btn-block btn-lg">Go Back</a>

</form>
 </div>
 </div>
<div class="clearfix">&nbsp;</div>

这是一个脚本错误,我的网站无法验证ref链接,我也认为ref链接通常类似于?= ref,?ref =,或接近它的东西。

现在检查脚本使用Cookie的网址点击次数。 每当我尝试访问自己的表单时,我都会收到Instant 404错误。似乎有什么问题呢? enter image description here

用我的php文件 -

<?php
//status.php?id=USER_ID
include('db.php');

if($_GET['id'])
{

//variables
$id=mysqli_real_escape_string($db,$_GET["id"]);

//selecr from database
$sql_query = "SELECT * FROM referral WHERE id='$id'";
$result_set=mysqli_query($db,$sql_query) or die('error');
$ref_row=mysqli_fetch_array($result_set); //fetch the result from table
$count=$ref_row['clicks'];
$user=$ref_row['user'];

}

?>






<?php 
if($ref_row)
{
echo "<div class='col-md-6 col-lg-5 col-sm-8 center-block well login-form'><h2 class='par no-margin text-center'>Total Clicks</h2><p class='inmt no-margin text-center'>$user Refer $count Users</p></div></div>";
}
else
{
echo "<div class='col-md-6 col-lg-5 col-sm-8 center-block well login-form'><h2 class='par no-margin text-center'>OOps</h2><p class='inmt no-margin text-center'>404 Page boss</p></div></div>";
}
?>

**Took out unnecessary codes

0 个答案:

没有答案