0
<?php
    require_once('auth.php');
 
    define('DB_HOST', 'xxx');
    define('DB_USER', 'xxx');
    define('DB_PASSWORD', 'xxx');
    define('DB_DATABASE', 'xxx');
 
	$connection = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
		if(!$connection) {
	die('Connection error: ' . mysql_error());
	}
 
	$selectdb= mysql_select_db(DB_DATABASE);
		if(!$selectdb) {
	die('Unable to select database: ' . mysql_error());
	}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>xxx</title>
<link rel="stylesheet" href="xxx.css">
<head>
</head>
<body>
<div id="xxx">
<table width="200" border="1">
 <tr>
	<th scope="col">xxx</th>
	<th scope="col">xxx</th>
	<th scope="col">xxx</th>
	<th scope="col">&nbsp;</th>
 </tr>
 <tr>
	<th scope="col">xxx</th>
	<th scope="col">
	<?php
 
	$maxcount = mysql_query("SELECT maxcount FROM `xxx` WHERE id='1'");
	$result = mysql_fetch_array($maxcount);
	echo ($result[$maxcount]);
	?>
	</th>
	<th scope="col">
	<?php
 
	$count = mysql_query("SELECT count FROM `xxx` WHERE id='1'");
	$result = mysql_fetch_array($count);
	echo ($result[$count]);
	?>
	</th>
	<th scope="col">
	<?php
 
		$count = mysql_query("SELECT count FROM `xxx` WHERE id='1'");
		$count_result = mysql_fetch_array($count);
		$maxcount = mysql_query("SELECT maxcount FROM `xxx` WHERE id='1'");
		$maxcount_result = mysql_fetch_array($maxcount);
 
		if($count_result<$maxcount_result)
		 {
 
			$sql = mysql_query("UPDATE xxx SET count=count+1 WHERE id='1'");
 
		}
 
		else
 
		{
			die;
		}
 
		  echo '<form action="'.$_SERVER['PHP_SELF'].'" method="GET" >'."\n";
		  echo '<input type="submit" name="submit" value="xxx"><br>'."\n";
		  echo '</form>'."\n";
	?>
	</th>
 </tr>
 </table>
</div>
</body>
</html>

I would want use javascript confirm box when submit on line 76 is clicked. How should it be done? The thing is I'm totaly new with javascript and can't get this work. So, could use some help.

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by lps
1
//php
echo '<form onsubmit="confirmation()" action="'.$_SERVER['PHP_SELF'].'" method="GET" >'."\n";


//javascript
function confirmation() {
    var answer = confirm("submit?")
    if (answer){
        return true;
    }
    else{
        return false;
    }
}

Edited by Nick Evan: Fixed formatting

0

You're welcome. But, if the problem is solved,please click the 'solved' link to mark the thread as solved thread. Thank you.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.