-
Php with Javascript
Hi,
I'm trying to use a JS function within PHP and cant seem to get it to call. Basically, after the users has entered thier details I want a pop up box to appear.
Heres my Code:
<head>
<script type="text/javascript">
<!--
function prompter() {
var reply = prompt("Hey there, good looking stranger! What's your name?", "")
alert ( "Nice to see you around these parts " + reply + "!")
}
//-->
</script>
</head>
<!--
function prompter() {
alert ( "Nice to see you around these parts " + reply + "!")
}
//-->
</head>
<body>
<?php
// Make a MySQL Connection
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
// Insert a row of information into the table "emp"
mysql_query("INSERT INTO test
(Number) VALUES('$_POST[Emp_no]' ) ")
or die(mysql_error());
?>
prompter()
</body>
Any help would be greatly appricated
-
Re: Php with Javascript
The function call is not in proper context (within <script> tags, in this case).
PHP Code:
<?php
// Make a MySQL Connection
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
// Insert a row of information into the table "emp"
mysql_query("INSERT INTO test
(Number) VALUES('$_POST[Emp_no]' ) ")
or die(mysql_error());
?>
<head>
<script type="text/javascript">
<!--
function prompter() {
var reply = prompt("Hey there, good looking stranger! What's your name?", "")
alert ( "Nice to see you around these parts " + reply + "!")
}
prompter()
//-->
</script>
</head>
<body></body>
-
Re: Php with Javascript
Thats worked, thank you kindly for your fast response