Re: Inserting Javascript code into PHP file

From: Date: Mon, 27 Nov 2000 12:39:59 +0000
Subject: Re: Inserting Javascript code into PHP file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-27354@lists.php.net to get a copy of this message
Hi! first of all i hope you haven"t forget the print command like in your code below :) you select in yur mySQL query all rows! and then it checks all, that means that print, having 100 users in the db, 99 times the alert and 1 times the ok-js source. <? if($name) { $myconnect = mysql_connect("localhost","root"); $myresult = mysql_db_query("myDB", "select name fromchatroom where name='$name'" ); if (mysql_num_rows($myresult)>0){ print "OK...."; } else { print "Whatchew talkin' 'bout, Willis?"; } } else { print "You've to enter your name."; } ?> regards Folke -- Folke Ashberg Stage Internet Services GmbH Technical Development folke@fanstage.de folke@fanstage.de | Tel: +49 89 454591-77 | Fax: +49 89 454591-71 Kreillerstr. 21 | 81673 Munich | Germany | www.fanstage.de On Mon, 27 Nov 2000, Thomas Edison Jr. wrote: > 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/ > >

« previous php.general (#27354) next »