Inserting Javascript code into PHP file
| From: | Thomas Edison Jr. | Date: | Mon, 27 Nov 2000 11:07:29 +0000 |
| Subject: | Inserting Javascript code into PHP file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-27335@lists.php.net to get a copy of this message | ||
I'm trying to inserty JS code into my PHP file. It's a
bit complicated...somehow..logically it should work..
but it's not working.
On submitting a form...I'm calling the same file in
action. I want the file to check from mySQL database
wether the same name doesn't exist which the user is
entering. If yes, give an alert and stay on same pgae
- if No, proceed with next pages...
This is what i'm doing ...
<?
if($name) {
$myconnect = mysql_connect("localhost","root");
$myresult = mysql_db_query("myDB","select name from
chatroom order by name desc");
while($myarray = mysql_fetch_array($myresult)){
if($name == $myarray[name]){
?>
<script language="javascript">
alert('Sorry, this name is already in use. Please
choose another name & re-login');
location.href="index.php3";
document.f1.name.focus();
</script>
<?
}
else {
?>
<script language="javascript">
parent.post.location="post.php3?name=<?php echo $name
?>&ss=<?php echo $PHPSESSID ?>";
parent.rooms.location="rooms.php3";
parent.main.location="main.php3";
</script>
<?
}
}
}
?>
As it's a frameset, different files have to be opened
in different frames.. which explains the js code for
frame locations.
What is wrong with this? It is accepting any user and
is running along.
Regards,
T. Edison jr.
=====
Rahul S. Johari (Director)
******************************************
Abraxas Technologies Inc.
Homepage : http://www.abraxastech.com
Email : abraxastech@yahoo.com
Tel : 91-4546512/4522124
*******************************************
__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/