<?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.

Recommended Answers

All 3 Replies

//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;
    }
}

Thank you, sir!

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.