PHP - Using Javascript In An If Statement
Hi,
I'm trying to work out how I can trigger a javascript popup type box in an if statement, to trigger it normally from a button it would be : Code: [Select] <input type="button" value="Display" onclick="javascript: formFunction();" class="submit" /> But I want to use it when people submit a form without filling in some of the fields so something like this : Code: [Select] if (($_POST['first_name'] == '')) { run javascript popup } Any ideas ? Many thanks in advance. Scott Similar TutorialsI have this javascript code that loads in the footer. I only need this javascript to load on a static home page, not on all other pages.
<script type="text/javascript"> var banner = (function(){ $('.banner').unslider({ speed: 1000, // The speed to animate each slide (in milliseconds) delay: 999000, // The delay between slide animations (in milliseconds) complete: function() {}, // A function that gets called after every slide animation keys: false, // Enable keyboard (left, right) arrow shortcuts dots: false, // Display dot navigation fluid: true // Support responsive design. May break non-responsive designs }); $( '#nav li:has(ul)' ).doubleTapToGo(); }); </script> <script> jQuery(document).ready(function() { jQuery('.nav-toggle').click(function(){ //get collapse content selector var collapse_content_selector = jQuery(this).attr('href'); //make the collapse content to be shown or hide var toggle_switch = jQuery(this); jQuery(collapse_content_selector).toggle(function(){ if(jQuery(this).css('display')=='none'){ toggle_switch.html('View All Services');//change the button label to be 'Show' }else{ toggle_switch.html('Hide Services List');//change the button label to be 'Hide' } }); }); }); </script> <script> jQuery(document).ready(function() { jQuery('.navtop-toggle').click(function(){ //get collapse content selector var collapse_content_selector = jQuery(this).attr('href'); //make the collapse content to be shown or hide var toggle_switch = jQuery(this); jQuery(collapse_content_selector).toggle(function(){ if(jQuery(this).css('display')=='none'){ toggle_switch.html('Menu');//change the button label to be 'Show' }else{ toggle_switch.html('Hide Menu');//change the button label to be 'Hide' } }); }); }); </script>So far I have this php statement, but I'm having trouble wrapping it in this php code. <?php if ($page=="home") echo " "; ?>I'm not sure if putting the whole javascript code above is a good idea in the echo quotes. Is there an easier or better way of wrapping javascript in PHP? Your help appreciated. I'm having issues with the following: Code: [Select] <?php session_start(); $_SESSION['username']=$_POST['username']; $_SESSION['password']=$_POST['password']; if($_SESSION['username']=="username" && $_SESSION['password']=="password"){ if($_GET['product']=="add"){ $content.=' <p><label>Product Name:</label> <input type="text" name="product_name" size="30" /> <label>Product Price:</label> <input type="text" name="product_price" size="5" /> </p> <p><label>Product Category:</label> <input type="text" name="product_category" size="30" /></p> <p><label>Product Link:</label> <input type="text" name="product_link" size="30" /></p> <p><label>Product Image:</label> <input type="text" name="product_image" size="30" /></p> <p><label>Product Tag:</label> <input type="text" name="product_tag" size="30" /></p> <p><label>Product Keywords:</label> <input type="text" name="keyword" size="30" /></p> <p><label>Product Features:</label><br /> <textarea name="product_features" rows="10" cols="60"></textarea> </p> <p><label>Product Pros:</label><br /> <textarea name="product_pros" rows="5" cols="30"></textarea> </p> <p><label>Product Cons:</label><br /> <textarea name="product_cons" rows="5" cols="30"></textarea> </p> <p><label>Product Description:</label><br /> <textarea name="product_description" rows="10" cols="60"></textarea> </p> <p><label>Product Notes:</label><br /> <textarea name="product_notes" rows="5" cols="30"></textarea> </p> '; $logout='<div><a href="./acp_admincp.php?log-out">Log-Out</a></div>'; } elseif($_GET['product']=="view"){ } else{ $content.=' <a href="./admincp.php?product=add">Add New Product</a> <br /> <a href="./admincp.php?product=view">View Products</a> '; } } elseif(isset($_GET['log-out'])){ session_start(); session_unset(); session_destroy(); header("Location: ./admincp.php"); } else{ $content=' <form action="./admincp.php" method="post"> <p><label>Username:</label> <input type="text" name="username" size="30" />'; $content.='</p> <p><label>Password:</label> <input type="password" name="password" /></p>'; $content.='<p><input type="submit" value="Submit" name="Submit" /></p> </form>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <base href="http://ghosthuntersportal.com/" /> <title>Ghost Hunter's Portal - Admin Control Panel</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="verify-v1" content="" /> <meta name="keywords" content="ghost, hunters, hunter, ghosts, spirit, spirits, paranormal, investigation, investigator, investigators, k2, emf, meter, kii" /> <meta name="description" content="Ghost Hunters Potal. Parnormal research equipment store." /> <meta name="author" content="Andrew McCarrick" /> <meta name="robots" content="index, follow" <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <img src="./logo.png" alt="Ghost Hunter's Portal Admin Control Panel" /> <br /> <div style="color: #AA44AA; font-size: 26px; margin-top: -30px; margin-left: 125px;">Admin Control Panel</div> <?php echo $logout; echo $content; ?> </body> </html> I can log-in, and get to the page with the two links on it. However, once I click one of the links it falls back to the log-in page, and it ends up being a never ending loop. It's doing this: Log-In --> Page with links ---> Log-In page again Should be doing this: Log-In --> Page with links --> Add Product page or View Products page I can never get into the the actual sub page. Just to be clear, the address bar actually shows product=add or product=view, but it still shows the log-in page. Hello Everyone, I have to change the if statements to a switch statement, in this game. Can anyone help? Thanks. var checkKeyPressed = function (e) { // Press key A or key D to make dog run to the left or right // The running speed is specified by the step variable, 10 by default. // If you replace 10 with a larger integer, the dog will run faster. //press A, dog runs left if (e.keyCode == "65") { if (prex[0] > 5) { prex[0] = prex[0] - step; } } //press D, dog runs right if (e.keyCode == "68") { if (prex[0] < right) { prex[0] = prex[0] + step; } } }; Hello I'm hoping someone here can help me with this. I know very little PHP I'm afraid but I think what I want to do is fairly basic and should be relatively simple. I have a footer which is referenced on each page of the site with <?php include($DOCUMENT_ROOT."/includes/php/footer.php"); ?> Within the footer I want it so that if it's the home page (default.php) it displays just the footer but for any other page I want it to display a Div and then the footer. Here is what I have so far but it isn't working: <?php if ($_SERVER['REQUEST_URI'] == "default.php") { ?> <!--Home Page Footer--> <div class="footer"> <div class="footer1"> </div> <div class="footer2"> </div> <div class="footer3"> </div> <div class="footerLinks"> <?php include($DOCUMENT_ROOT."/includes/php/bottomlinks.php"); ?> </div> <div class="footer4"> </div> </div> <?php } else { ?> <!--Blue Footer Image--> <div class="footer2"> </div> <!--Footer--> <div class="footer"> <div class="footer1"> </div> <div class="footer2"> </div> <div class="footer3"> </div> <div class="footerLinks"> <?php include($DOCUMENT_ROOT."/includes/php/bottomlinks.php"); ?> </div> <div class="footer4"> </div> </div> <?php } ?> I don't know that the request uri address is correct but when I've tried to use 'echo $_SERVER['REQUEST_URI']' to find out what it should be I can't get that to work either. I'm new here, this is my first post. Sorry if it's too basic or I've made a forum faux pas. Any help would be extremely appreciated. I need help with my if/else statement. Code: [Select] function show_list() { $query = "SELECT show_id,show_name,host,description_short,show_graphic1 FROM shows"; $result = mysql_query($query) or die(mysql_error()); echo "<table>"; while($row = mysql_fetch_array($result)) { echo "<tr> <td rowspan='3' width='155' class='show_image'> <a href='". $site ."show_page.php?show_id=". $row['show_id'] ."'> <img src='". $site ."images/". $row['show_graphic1'] ."' height='150' width='150'></img></a> </td> <td class='show_name'> <h1>"; if ($row['host'] == "") { echo $row['show_name']" with " $row['host']; } else { echo $row['show_name']; } echo " </h1> </td> </tr> <tr> <td height='100'>" . $row['description_short'] . "</td> </tr> <tr> <td align='right'> <a href='". $site ."show_page.php?show_id=". $row['show_id'] ."'>More Info</a> </td> </tr>"; } echo "</table>"; } This function is for a page showing a list of shows from a database. Not all shows have a host. So it does not need to show "with host name" for those shows. I tried if / else statement stating that if there "is" data in the row to display one thing and if there "is not" data in the row to display another. Here is that piece of code. Code: [Select] if ($row['host'] == "") { echo $row['show_name']" with " $row['host']; } else { echo $row['show_name']; } I keep getting this error "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/ansonb/lwr_config.php on line 46" What am I doing wrong ? I'm sure it is something simple, I just can't figure it out. Hi there can anybody help me please? my if statement isnt working?? All i am trying to do is display an image if the session variable is == entered varialble "Empire" I get the error message "Parse error: syntax error, unexpected T_VARIABLE, expecting " Code: [Select] if $_SESSION['MM_Username'] == 'Empire'{ echo'<img src="Images/empicon.jpg" width="20" height="20" class="moncalimari"/>' ; } ?> I have checked and the session does == Empire Please help Thank you. Hi all, I have the below which triggers an alert box when the user is redirected to the index page. <?php if(!empty($_SESSION['reg'])) { echo '<div id="alert">' . $_SESSION['reg'] . '</div>'; unset($_SESSION['reg']); } if(!empty($_SESSION['fail'])) { echo '<div id="alertr">' . $_SESSION['fail'] . '</div>'; unset($_SESSION['fail']); } if(!empty($_SESSION['logged'])) { echo '<div id="alertr">' . $_SESSION['logged'] . '</div>'; unset($_SESSION['logged']); } if(!empty($_SESSION['failedlog'])) { echo '<div id="alertr">' . $_SESSION['failedlog'] . '</div>'; unset($_SESSION['failedlog']); }?> It only works when session ['reg'] contains a value. I guess I can not use if statements in this way but not quite sure what I should be using? Many Thanks hi how do u do a if statement so that if <a href="TaxiEntry1.php?Quote_ID='.$qid.'">Accept</a> is clicked then update this field in this table } thanks I have a query that outputs certain values in a table, but i want to put a conditional if statement. What i have right now is if the status is 1 echo Close and if the status is 0 Open what i want it to do now is not to show the values that have 1 along with all the other database table entries how would i do that Code: [Select] //if statement for status if($rows['status'] == 1) { $status = "Close"; } else $status = "Open"; ?> this if statement isn't working.. $newid is an integer, which is the name of a variable of an array e.g. $53. The below code should check if the array exist. it should echo yes.. instead it is blank. Code: [Select] if(isset(${"$newid"})) { echo "yes"; //code } I think I know the answer to this, but it would make things easier if I could do what I think I can't. Can I use LIKE and NOT LIKE in an if statement? Doesn't seem to be working for me. Code: [Select] <?php //$rightlic is a twelve character string ending either P00, P01, V00, or V01. I want to do different things based on V or P if ($rightlic not like '%V00' AND $rightlic not like '%V01'){ echo "<br>purchaser ran demo as public but is now trying to purchase a private account. Stop the process."; exit; } ?> Can I do something like this or do I have to separate the string and look for the last characters that way? Thanks in advance for any help. Hello all, I need your help. I have two pages. This is the 1st page: <?php include "include/dbc.php"; include "include/header.inc"; ?> <style type="text/css"> .mydate{ color:#00F; text-decoration:underline; cursor:pointer; } </style> <script type="text/javascript"> function displayDate(d){ var date=new Date(); var D=date.getDate(); date.setDate(D+d); var YYYY=date.getFullYear(); var MM=date.getMonth()+1; MM<10?MM='0'+MM:null; var DD=date.getDate(); DD<10?DD='0'+DD:null; var span=document.getElementById('date'); span.innerHTML= 'Entries for '+MM+'/'+DD+'/'+YYYY; } onload=function(){displayDate(0)}; </script> <h1>Food Diary</h1> <div class="full"> <center><div><span class="mydate" onclick="displayDate(-1)"><img src="images/left_arrow.png" border="0">Yesterday</span> <span id="date" style="font-size:2em;"></span> <span class="mydate" onclick="displayDate(1)">Tomorrow<img src="images/right_arrow.png" border="0"></span></div><br /> <a href="#" onclick="displayDate(0);return false;">Today</a> </center> <div class="full"> <form name="exercise" id="exercise" method="GET" action=""> <center><table> <tr> <td><h3>Add an Activity</h3></td> </tr> <tr> <td><input name="NewSearchString" style="width: 100px" type="text"/> <input type="submit" value="Search" /> </td> </tr> <tr> <td> <select name="activity"> <option value="_">Activity Browse...</option> <option value="all">All Activities</option> <option value="biking">Biking</option> <option value="condition">Conditioning</option> <option value="dancing">Dancing</option> <option value="fish">Fishing & Hunting</option> <option value="Home">Home Activities</option> <option value="misc">Miscellaneous</option> <option value="music">Music Playing</option> <option value="occupation">Occupation</option> <option value="running">Running</option> <option value="sports">Sports</option> <option value="walking">Walking</option> <option value="water">Water Activities</option> <option value="winter">Winter Activities</option> </select> <input type="submit" value="Submit" /></td></tr></table></center></form> </td> </tr> </table> </center> <table width="100%"> <tr bgcolor="#66CC33"> <td><div>Activity</div></td> <td><div>Specific Activity</div></td> <td><div>Time (hh:mm)</div></td> <td><div>Distance</div></td> <td><div>Units</div></td> </tr> <tr bgcolor="#66CC33"> <td><div></div></td> <td><div></div></td> <td><div></div></td> <td><div class="Float"></div></td> <td class="cp_Distance"><div></div></td> </tr> <?php if(isset($_GET[activity])) { $category=$_GET[activity]; $result = mysql_query("SELECT * FROM exercise WHERE type='$category'"); ?> <form action="add_activity.php" method="POST"> <?php while($row = mysql_fetch_array($result)) { echo '<tr><td><div>'.$row[Type].'</div></td>'; echo '<td><div>'.$row[Name].'<input type="hidden" name="exerciseid[]" value="'.$row[Name].'"></div></td>'; echo '<td><div><input type="text" name="duration['.$row['Name'].']" value=""></div></td>'; echo '<td><div><input type="text" name="distance['.$row['Name'].']" value ""></div></td>'; echo '<td><div><select name="metric[]"> <option value="mile" name="mile">mile</option> <option value="Km" name="Km">km</option> <option value="M" name="M">m</option> <option value="Yard" name="yard">yrd</option> <option value="Feet" name="feet">ft</option> </select></div></td></tr>'; } mysql_close(); ?> <tr><td colspan="6" align="center"><input type="submit" name="submit" value="Add Activities" onClick="return confirm( 'Are you sure you want to submit the activities?');"></td></tr> </form> <?php } ?> <tr bgcolor="#66CC33"> <td><div></div></td> <td><div></div></td> <td><div></div></td> <td><div class="Float"></div></td> <td class="cp_Distance"><div></div></td> </tr></table> This page contains a table that is pulling info from a database stored in phpmyadmin. The values entered in that table are passed to the second page: <?php include "include/dbc.php"; include "include/header.inc"; $exerciseid = $_POST["exerciseid"]; $duration = $_POST["duration"]; $distance = $_POST["distance"]; $metric = $_POST["metric"]; echo'<h1>Added Activities</h1>'; // name of array echo '<h1>Exercise</h1>'; if (is_array($exerciseid)) { foreach ($exerciseid as $key => $value) { echo $key .' : '. $value .'<br />'; } } echo '<h1>Duration</h1>'; if ($duration == ""){ echo "No value"; } // name of array echo '<h1>Distance</h1>'; if (is_array($distance)) { foreach ($distance as $key => $value) { echo $key .' : '. $value .'<br />'; } } // name of array echo '<h1>Metric</h1>'; if (is_array($metric)) { foreach ($metric as $key => $value) { echo $key .' : '. $value .'<br />'; } } ?> The problem is that ALL the values, empty or w/content, are being passed. So I was wondering if there was a way to pass only user input with an if/else statement. Something like: if ($duration == ""){ echo "No value"; else echo duration; } This, however, is not working and I would like to know what possibly could work that would be structured similarly. Thanks in advance. Can someone write me some simple code to check to see if the url has the word "soundcloud" in them. This is what I want to do.... This is my code now... Code: [Select] echo " <h3> $title - $author</h3> </br> <iframe width='640' height='360' src='$link' frameborder='0' allowfullscreen></iframe> </br> </br> $message </br> <font color='#8b8d9b' size='1'>Posted By: $username $date</font> </br></br></br></br></br> "; However I want to pull the link value out of the database and see if it contains the word "soundcloud" and if it does do this...(note the height is changed) Code: [Select] echo " <h3> $title - $author</h3> </br> <iframe width='640' height='100' src='$link' frameborder='0' allowfullscreen></iframe> </br> </br> $message </br> <font color='#8b8d9b' size='1'>Posted By: $username $date</font> </br></br></br></br></br> "; Any help would be greatly appreciated. I have a table on a page that displays info from a database and everything is working fine but I want it so if the user entered data from another page to a certain field then the row on my data display table will turn red. Right now I have a If statement in every row of my table. Is it possible to have two if statements in a row? Here is my page code with the table. <? include "include/session.php"; include "include/z_db.php"; ?> <? require "bottom.php"; ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> </head> <!-- <body bgcolor="#339999"> --> <body bgcolor="white"> <img src="logo.jpg" width="197" height="193" align="right"><br /><br /><br /><br /><br /> <br /><br /><br /><br /><br /> <FORM> <INPUT TYPE="BUTTON" VALUE="New Tour" ONCLICK="window.location.href='http://www.integranite.net/EAToursDemo/Input.php'"> </FORM> <?php $result = mysql_query("SELECT * FROM Project"); ?> <div style="overflow:auto; height:30px; width:1650px"> <?php echo "<table border='1'> <tr> <th width='200'>School</th> <th width='200'>Teacher</th> <th>First Contact start date</th> <th>Development Start</th> <th>Development End</th> <th>Pricing Start</th> <th>Pricing End</th> <th>Marketing Start date</th> <th>Price Based On</th> <th>Trip Assigned To</th> <th>Trip Made</th> <th width='104'>Notes</th> </tr>"; echo "</table>"; echo "</div>"; ?> <div style="overflow:auto; height:400px; width:1650px"> <?php while($row = mysql_fetch_array($result)) { $checkbox = ''; if ($row['TripMade'] == 1) $checkbox = ' checked'; ?> <!--<div style="overflow:auto; height:40px; width:155px">--!> <table cellpadding="0" cellspacing="0" style="width:50px;"> <?php echo "<table border='1'>"; echo "<tr>"; echo "<td width='200'>" .$row['School'] . "</td>"; echo "<td width='200'>" .$row['Teacher'] . "</td>"; if(!strcmp($row['dtFirstContactSt']&& $row['dtMarketingSt'] , '0000-00-00' && '0000-00-00')) { echo "<td width='156'>" . "  </td>"; } else { echo "<td bgcolor=FF0000 width='156'>" .$row['dtFirstContactSt']. "</td>"; } if(!strcmp($row['dtDevelopmentSt'], '0000-00-00')) { echo "<td width='126'>" . "  </td>"; } else { echo "<td width='126'>" .$row['dtDevelopmentSt']. "</td>"; } if(!strcmp($row['dtDevelopmentEnd'], '0000-00-00')) { echo "<td width='119'>" . "  </td>"; } else { echo "<td width='119'>" .$row['dtDevelopmentEnd']. "</td>"; }; if(!strcmp($row['dtPricingSt'], '0000-00-00')) { echo "<td width='83'>" . "  </td>"; } else { echo "<td width='83'>" .$row['dtPricingSt']. "</td>"; } if(!strcmp($row['dtPricingEnd'], '0000-00-00')) { echo "<td width='76'>" . "  </td>"; } else { echo "<td width='76'>" .$row['dtPricingEnd']. "</td>"; } if(!strcmp($row['dtMarketingSt'], '0000-00-00')) { echo "<td width='142'>" . "  </td>"; } else { echo "<td width='142'>" .$row['dtMarketingSt']. "</td>"; } echo "<td width='104'>" .$row['PriceBasedOn']. "</td>"; echo "<td width='115'>" .$row['TripAssignedTo']. "</td>"; ?> <td width="72"><input type="checkbox" name="TripMade" value="Yes" <?= $checkbox ?>></td> <td><textarea name="Notes" rows="1" cols="10"><?php echo $row["Notes"]?></textarea> </td> <?php echo "<td>" . "<a href=Edit_Form.php?UniqueIdentifier=$row[UniqueIdentifier]> Edit </a></td>"; echo "</tr>"; } echo "</table>"; echo "</div>"; mysql_close($con); ?> <br /> <meta name="GENERATOR" content="Arachnophilia 4.0"> <meta name="FORMATTER" content="Arachnophilia 4.0"> </head> <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000"> <center> </body> </html> The first IF statement is what i am trying to do but just dont know how to code it. I know its kind hard to understand but any help is appreciated. Good morning,
I am trying to return specific values depending on the value of the WJCStatusID, for example if WJCStatusID = < 4 but > 2 return "In production"
SQL QUERY:
SELECT tblWJCItem.AddedDescription, tblWJC.WJCPrefix + Convert(Varchar(10),tblWJC.WJCNo) AS OurRef, tblWJCItem.MaterialName, tblStockFamily.StockFamily, tblWJCItem.WeightToSend, tblWJC.DateCreated, tblWJC.WJCStatusID FROM tblWJC INNER JOIN tblWJCItem ON tblWJC.WJCID = tblWJCItem.WJCID INNER JOIN tblStockFamily ON tblWJCItem.ProductFamilyID = tblStockFamily.StockFamilyID IF (tblWJC.WJCStatusID) < 2 THEN 'Pre Production' ELSE IF (tblWJC.WJCStatusID) < 4 THEN 'In Production' ELSE IF (tblWJC.WJCStatusID) > 4 THEN 'Ready To Ship' ELSE 'Awaiting Lab Results';I am quite new to the world of mssql so I maybe doing something wrong which is quite simply to fix. Can any body help? I've never really had this problem before. I'm trying to make it so only moderators can edit titles. This is currently my if statement: elseif($type == 2 && acc_status(getUsername()) > 1 && !isset($_POST['title']) || !isset($_POST['content'])) (I can assure you getUsername() works) Interpretation: If the editing type is 2 (thread/topic) and the user's account status is higher than 2 (meaning admin & mod) and the title or message/content isn't set, display the content within the if statement block. Why is it users with a user status of 1 can see the information within the block statement, allowing them to see the "edit title" field? Hi I am trying to perform an echo yes if field from query is equal to one or no if anything else. See the code below, Now its erroring saying unexpected t variable in string and its also saying expecting ' It seems to be erroring at the start of my IF statement. So can anyone please help with what I have done wrong. This will be my first personal written IF statement so if it is miles off i apologise. <?php $qGetCat = ("SELECT * FROM category ORDER BY `id`"); $rGetCat = mysql_query($qGetCat) or die(mysql_error()); while($Cat = mysql_fetch_assoc($rGetCat)) { ?> <td height="31" align="left" nowrap="nowrap"><?= $Cat['id'] ?></td> <td align="left" nowrap="nowrap"><?= $Cat['cat1'] ?></td> <td align="left" nowrap="nowrap"> <?php if $Cat['top']='1' { echo "Yes";} else { echo "No";} ?> </td> <td><a href="updatetopcategory.php?=<?= $Cat['id'] ?>"><img src="../images/Edit.png" width="29" height="29" /></a></td> <td><img src="../images/delete.jpg" width="29" height="29" /></td> <? } ?> Code: [Select] <?php mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("Regis") or die(mysql_error()); $m=$_POST['message']; if (isset($_POST['submit'])) { // makes sure they filled it in // checks it against the database $check = mysql_query("SELECT * FROM registration WHERE username = '".$_POST['username']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('That user does not exist in our database')</SCRIPT>") ?> <html><head></head><body> <form name="register" method="post" action="login.php" onsubmit="return a()"> <table border='0'> <input type="hidden" name="message" value="<?php echo $m;?>"> <tr><td>Username:</td><td><input type="text" name="username" maxlength="60"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="10"></td></tr> <tr><td>Confirm Password:</td><td><input type="password" name="pass2" maxlength="10"></td></tr> <tr><th colspan=2><input type="submit" name="sub" value="Register"></th></tr></table> </form> </body> </html> <? while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); } } } else { ?> <html> <head> <script type="text/javascript"> function addsmiley(code) { var pretext = document.smile.message.value; this.code = code; document.smile.message.value = pretext + code; } function a() { var x = document.smile.message.value; if(x=="") { alert("Please insert an message!"); return false; } } </script> <style type="text/css"> body{ background-color: #d8da3d } </style> </head> <body> <form name="smile" method="post" action="registration.php" onSubmit="return a()" > <input type="hidden" name="message" value="<?php echo $m;?>"> Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <img src="smile.gif" alt=":)" onClick="addsmiley(':)')" style="cursor:pointer;border:0" /> <img src="blush.gif" alt=":)" onClick="addsmiley('*blush*')" style="cursor:pointer;border:0" /> <input type='submit' name='submit' value='Set Name' class='biasa' ></form> <br> <br> </body> </html> <?php } ?> im doing if statments if the $check2==0 it will show the registration form and else it will show the form name="smile" method="post" action="registration.php" onSubmit="return a()" > <input type="hidden" name="message" value="<?php echo $m;?>"> Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <img src="smile.gif" alt="" onClick="addsmiley('')" style="cursor:pointer;border:0" /> <img src="blush.gif" alt="" onClick="addsmiley('*blush*')" style="cursor:pointer;border:0" /> <input type='submit' name='submit' value='Set Name' class='biasa' ></form> but my problem is it cannot direct to else matter although the name is already in database may i know which error is wrong or the if statement is wrong |