<script>
function buttonClick(){
var total = 0;
var type = "";
for(var i=1;i<=3;i++) {
var id = "max_clicks" + i;
var label = "label" + i;
var badge = "badge" + i;
if (document.getElementById(id).checked!=null && document.getElementById(id).checked==true) {
total += parseInt(document.getElementById(id).value);
type +="Max-clicks:<hr style='margin-top:-1px;' />"+ "<span class='badge' style='margin-top:-5px;'>" + document.getElementById("label"+i).innerHTML + "</span> : <span class='badge' style='margin-top:-5px;'>" + document.getElementById("badge"+i).innerHTML + "</span><br />";
}
}
document.getElementById('Totalcost').innerHTML = total;
document.getElementById('individual').innerHTML = type;
}
</script>
<form action="<?php echo "".site_url."";?>/magaza/reklam-ver" method="post" enctype="multipart/form-data">
<input type="checkbox" name="max_clicks[]" id="max_clicks1" value="<?php echo "".$price1."";?>" onClick="buttonClick(this);">
<label id="label1" class="badge" style="background:#fc5a5d;"> 150 clicks</label>-<span class="badge" id="badge1">Price: 5 credits</span><br />
<input type="checkbox" name="max_clicks[]" id="max_clicks2" value="<?php echo "".$price2."";?>" onClick="buttonClick(this);">
<label id="label2" class="badge" style="background:#fc5a5d;"> 400 clicks</label>-<span class="badge" id="badge2">Price: 13 credits</span><br />
<input type="checkbox" name="max_clicks[]" id="max_clicks3" value="<?php echo "".$price3."";?>" onClick="buttonClick(this);">
<label id="label3" class="badge" style="background:#fc5a5d;"> 735 clicks</label>-<span class="badge" id="badge3">Price: 9 credits</span><br />
<span id="individual" class="badge" style="background:#f29d9d;">You dont have any select item.</span>
<button type="button"class="btn btn-primary" onclick="buttonClick()">Price to pay:
<span class="badge"><span id="Totalcost">0</span> credits</span></button>
<input class="btn btn-success" style="float:right;" type="submit" name="add_ad" value="Reklam satın al">
</form>
我试图获取检查项目并发送到mysql ...所有工作但发送到mysql有问题我想发送<span>
.... </span>
的最大点击-info和用输入值检查价格并将其发送到mysql - 最大点击次数 - 值关闭<span>
.. </span>
和输入值的任何想法?我给我的脚本form.php和action_form.php抱歉我的语言:/
if($_POST['add_ad'])
{
if(!empty($_POST['max_clicks'])) {
$shipping_subtotal = 0;
foreach($_POST['max_clicks'] as $shipping){
$shipping_subtotal += $shipping;
}
$user = userInfo();
if($user['credits'] >= $shipping_subtotal){ //check user have enough credits or not
if($_POST['title'] && $_POST['target_url'])
{
$expires = strtotime("+1 month"); //Reklam 1 ay ekle
$title = quote_smart($_POST['title']);
$target_url = quote_smart($_POST['target_url']);
mysql_query("INSERT INTO ads (date_added,date_expires, target_url, clicks, author_id, title, max_clicks) VALUES ('".time()."',$expires, $target_url, '0', '".$_COOKIE['user_id']."', $title, $shipping_subtotal)") or die(mysql_error());
echo info("Success!");
delcredits($user['id'], $shipping_subtotal);
header ("refresh:3;url=".site_url."/magaza/reklam-ver");
}
else
{
echo error("Error.");
}
}
else
{
echo error("you dont have enough credits");
}
}
else{
echo "<b>Please select max-clicks.</b>";
}
}