Jump to content

How do I Auto insert to db without a form


Parabolundertow

Recommended Posts

Hi there,

 

I am trying to run a counter so when a person clicks on a banner, it updates the db with a new number.

I have called the banner link:  ad_counter.php?id=1

I have a field in my table called ad_counter

 

Then im setting a recordset to GET the data.

I am using:

 

$last = $row_Recordset1['ad_counter'];

$add = 1;

$ad_counter = $last + $add;

 

What I want to do is auto form fill and update the database, and proceed to their website without this process even being seen.

 

Is this possible without having to push the form submit button.

 

A basic statistics gatherer for businesses who wish to advertise.

 

Thankyou

hi skali

 

Thanks for the quick reply.

 

if($_GET['do']=='update && !empty($_GET['id']){

  //update your database counter.

}

 

How does this know which field in the table to update?

I want to update the field (ad_counter)

 

Should this work?

 

 

Hi guys,

 

Im still trying to make this work ...

Im hoping to call the ad_counter from the table using $_GET, add 1 and update, then go to a url.

 

here is my script:

<?php require_once('Connections/Farout.php'); ?>

<?php

if (isset($_GET['id'])) {

  $colname_rsBusinessclick = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);

}

mysql_select_db($database_Farout, $Farout);

$query_rsBusinessclick = sprintf("SELECT * FROM hub_directory WHERE id = '%s'", $colname_rsBusinessclick);

$rsBusinessclick = mysql_query($query_rsBusinessclick, $Farout) or die(mysql_error());

$row_rsBusinessclick = mysql_fetch_assoc($rsBusinessclick);

$totalRows_rsBusinessclick = mysql_num_rows($rsBusinessclick);

 

 

 

$ad_counter = $row_rsBusinessclick['ad_counter'];

 

if($_GET['do']=='update' && !empty($_GET['id']){

  mysql_query('update hub_directory set ad_counter = ad_counter +1 where id = {$_GET['id']}');

 

 

  $updateGoTo = "http://www.mywebaddress.com.au";

  if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {

    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";

    $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];

  }

  header(sprintf("Location: %s", $updateGoTo));  }

 

?>

 

 

 

Where am I going wrong ... ??

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.