2016-04-03 64 views
-1

我有一個頁面,更新user_points表其呼叫 pointsxxl50updateforposts.php 是自動更新他們自己的用戶分 我喜歡聞其提交的留言,提供50點提交後,這可能像因爲我有嘗試提交卻又無可奈何 這是我喜歡做這樣的事情去一些頁面提交後

<td><input type="submit" name="submit" id="submit" value="Submit Post" onclick="window.location.href='http://bitcoinrotator.publiadds.org.pt/login-registration/pointsxxl50updateforposts.php'"> 
    </td> 

,這是我的代碼對使用reCAPTCHA選項 該網頁,我喜歡留在驗證碼和提交後進入該頁面

http://bitcoinrotator.publiadds.org.pt/login-registration/pointsxxl50updateforposts.php 

<?php 
 
include("db.php"); 
 
    
 
$select=mysql_query("select * from commenttable"); 
 
while($row=mysql_fetch_array($select)) 
 
{ 
 
\t echo "<div id='sty'>"; 
 
\t echo "<img src='files/fav icon.png'"."' width='50px' height='50px' align='left' />"; 
 
\t echo "<div id='nameid'>".$row['name']."</div>"; 
 
\t echo "<div id='msgid'>".$row['message']."</div>"; 
 
\t echo "</div><br />"; 
 
} 
 
?> 
 
<!DOCTYPE HTML> 
 
<html> 
 
<head> 
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
 
<title>Comment system using php and mysql</title> 
 
<center><br><br><form> 
 
<input type="button" value="Back" onclick="window.location.href='http://bitcoinrotator.publiadds.org.pt/login-registration/home.php'" /> 
 
</form></center> 
 

 

 
<script type="text/javascript"> 
 
function validation() 
 
{ 
 
\t var nam=document.comment.namename.value; 
 
\t var nam1=document.getElementById('tnameid'); 
 
\t if(nam=="") 
 
\t { 
 
\t \t document.comment.namename.focus(); 
 
\t \t nam1.style.borderColor="#f00"; 
 
\t \t return false; 
 
\t } 
 
\t var nam1=document.getElementById('tnameid'); 
 
\t nam1.style.borderColor=""; 
 
\t var jo=document.comment.job.value; 
 
\t var jo1=document.getElementById('tjobid'); 
 
\t if(jo=="") 
 
\t { 
 
\t \t document.comment.job.focus(); 
 
\t \t jo1.style.borderColor="#f00"; 
 
\t \t return false; 
 
\t } 
 
\t var jo1=document.getElementById('tjobid'); 
 
\t jo1.style.borderColor=""; 
 
\t var mess=document.comment.message.value; 
 
\t var mess1=document.getElementById('tmessageid'); 
 
\t if(mess=="") 
 
\t { 
 
\t \t document.comment.message.focus(); 
 
\t \t mess1.style.borderColor="#f00"; 
 
\t \t return false; 
 
\t } 
 
} 
 
</script> 
 
</head> 
 

 
<body> 
 
<body bgcolor="#ffffff"> 
 
<center><form name="comment" method="post" action="comment.php" onSubmit="return validation()"> 
 

 
    
 
<table width="500" border="0" cellspacing="3" cellpadding="3" style="margin:auto;"> 
 
    <tr> 
 
    <td align="right" id="one">Name :<span style="color:#F00;">*</span></td> 
 
    <td><input type="text" name="namename" id="tnameid"></td> 
 
    </tr> 
 
    <tr> 
 
    <td align="right" id="one">Work :<span style="color:#F00;">*</span></td> 
 
    <td><input type="text" name="job" id="tjobid"></td> 
 
    </tr> 
 
    <tr> 
 
    <td align="right" id="one"></td> 
 
    <td><textarea name="message" id="tmessageid"></textarea></td> 
 
    </tr> 
 
    <tr> 
 
    <td align="right" id="one"></td></center> 
 
<?php 
 
require_once('recaptchalib.php'); 
 
      // Get a key from https://www.google.com/recaptcha/admin/create 
 
$publickey = "6LfFYRwTAAAAAKjhq4QOgfYXZP6aZ6OSJhNBPglV 
 
"; 
 
$privatekey = "6LfFYRwTAAAAAIqSCCYHobymWT98Jwooh9EwinjE"; 
 
# the response from reCAPTCHA 
 
$resp = null; 
 
# the error code from reCAPTCHA, if any 
 
$error = null; 
 

 
echo recaptcha_get_html($publickey, $error); 
 
?> 
 
    <td><input type="submit" name="submit" id="submit" value="Submit Post"> 
 
    </td> 
 
</tr> 
 
</table> 
 
</form></center> 
 

 
</body> 
 
</html>

回答

0

嗯,我只是解決了重定向問題提交

驗證碼有效的響應後後

if ($resp->is_valid) { 
 
       if(isset($_POST['submit'])) 
 
\t \t \t \t \t { 
 
\t \t \t \t \t \t $name=$_POST['namename']; 
 
\t \t \t \t \t \t $job=$_POST['job']; 
 
\t \t \t \t \t \t $message=$_POST['message']; 
 
\t \t \t \t \t \t $insert=mysql_query("insert into commenttable(name,job,message)values('$name','$job','$message')")or die(mysql_error()); 
 
\t \t \t \t \t \t echo "You posted a comment"; 
 
\t \t \t \t \t \t header("Location: mylink");