PHP - Echoing Form If Not Sent
i have a form, and if the form has not been sent, it shows the form. here is my code for the beginning:
Code: [Select] if($sent != true) { echo" ?> <div class='form'><form action='' method='post'> [b]!!![/b] <p class='form'>User ID: <br /><input name='memberID' type='hidden' value='<?php echo $row['id'] ?>' /> Your User ID will be logged for identity purposes. <br /><input type='checkbox' name='noIdentity' id='noIdentity' value='noIdentity' <?php if(isset($_POST['errors']) && isset($_POST[noIdentity])) { [b]!!![/b] echo ' checked='checked '"; } ?> /> and the end: Code: [Select] <?php "; } ?> it doesn't like what i have the exclamations next to. also, am i doing this right? Similar TutorialsHello, I'm having difficulty learning the most efficient method of echoing error messages on a form. The particular example I'm working on is a registration form which I have had functional but not perfected as of yet. I have been able to make the form work by using die() to kill the process and display a message however I would very much like for it to kill the process and simply echo an error message, same page, no redirects... I will post my code and hopefully someone with more knowledge than me can shed some light. Cheers! Code: [Select] <?php if (isset($_POST['submit'])) { //This is one error message I would like to display if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) { die('You did not complete all of the required fields'); } if (!get_magic_quotes_gpc()) { $_POST['username'] = addslashes($_POST['username']); } $usercheck = $_POST['username']; $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name already exists it gives an error here if ($check2 != 0) { die('Sorry, the username '.$_POST['username'].' is already in use.'); } // this makes sure both passwords entered match and should display an error if false if ($_POST['pass'] != $_POST['pass2']) { die('Your passwords did not match. '); } $_POST['pass'] = md5($_POST['pass']); if (!get_magic_quotes_gpc()) { $_POST['pass'] = addslashes($_POST['pass']); $_POST['username'] = addslashes($_POST['username']); } $insert = "INSERT INTO users (username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')"; $add_member = mysql_query($insert); ?> And here is the form it fits into Code: [Select] <?php } else { ?> <body> <div id="container"> <div id="header"><?php include ("login_header.php") ?></div> <div id="photoNav"><?php include ("mainNav.php") ?></div> <div id="tableContent"> <div class="bold_16" style="margin-top:40px">Enter Your Registration Information Below</div> <div class="padding_top"><div style="padding-top:10px; text-align:center;"> ***THIS IS WHERE I WOULD LIKE MY ERRORS TO DISPLAY*** </div> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" align="center"> <tr><td>Username:</td><td> <input name="username" type="text" size="23" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input name="pass" type="password" size="24" maxlength="12"> </td></tr> <tr><td>Confirm Password:</td><td> <input name="pass2" type="password" size="24" maxlength="12"> </td></tr> <tr><th colspan=2 style="text-align:right;"><input type="submit" name="submit" value="Register" style="margin-top:10px;"></th></tr> </table> </form> <?php } ?> </div></div> p.s is it just me or is it a real pain getting a message into this text-field?? Hi all, I have a html form list box that needs to show all the types of products that are for sale and have a number in the list box saying how many of that type are for sale. eg. If the mysql database looks like this productType | productDetails chair | outdoor large chair table | 2m x 1m chair | indoor chair chair | childs chair I would want the form list box to show the values inside as: chair (3) table (1) could someone give me the heads up on how to do this Thanks Hi, I used to do form validations in a totally different manner before this that aside. I would like to know how can I do something like this. What happens here is if none of the conditions are met I echo a div containing the error and so on. The problem I am facing is If the first condition is not met it goes to the second condition and at the end there are two error divs at the same time. I want to perform something like, if first condition is not met script stops, echos only the div where the condition is not met and the script does not carry on. If i use the die or exit functions it dies and html dies with it any solutions or another way? Code: [Select] if (strlen($title)<=19) { echo "<div id='error'><div id='error_img'><img src='images/warning.gif' width='16' height='16' title='error' /></div> must of be atleast 20 characters. </div>";; } if ($on=="-1") { echo "<div id='error'><div id='error_img'><img src='images/warning.gif' width='16' height='16' title='error' /></div> Please select. </div>"; } any help is appreciated thanks! Been screwing around on Google for about 3 hours trying to find a tutorial on what I am trying to do with absolutely no luck! I am simply trying to get my test script to echo errors from an array when a form criteria does not validate. This is my final revision which is still not working! Can someone please tell me what I am doing wrong? No matter what I do, I can't get away from this error: Notice: Undefined variable: error in C:\wamp\www\php\form_validation.php on line 13 <?php $o = $error[]; // test echo $o; // test if(!preg_match('/[^0-9A-Za-z]/',$_POST['first_name'])) { $error[] = "Please enter a valid First Name"; ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> First Name:<br /> <input name="first_name" type="text" size="50" maxlength="50" /><br /><br /> <input type="submit" /><br /><br /> </form> Hi all I have a field in mySQL table called dimensions. It has the double quote in in for inches - " When I echo the result from the mySQL query on the item page (Customer facing) it's fine. However, I have built a form so that the administrator can edit the dimensions in the admin panel and when I echo it out in to the form field it stops when it gets to the double quotes? Pete Hello guys, I want to get the values of 3rd level of my referral but it did not echo any value but if i put the ref id directly on the code, it will echo the values. why is it so? or am i doing it the wrong way? in my database i have a table test_referral id acct_name ref_id refer_id 1 john J1234 0 2 bull B3456 J1234 3 doe D5567 J1234 4 frank F7788 J1234 5 jimmy J9990 J1234 6 tommy T6784 F7788 7 tom T9988 F7788 8 girly G8866 D5567 9 fred F0099 J9990 10 ronaldo R7722 B3456 thanks $stmt= $pdo->query("SELECT * FROM test_referral WHERE acct_name='Chidi Okafor'"); $parent = $stmt->fetch(PDO::FETCH_LAZY); echo "<ul><li>"; echo $parent['acct_name']; $ref_id = $parent['ref_id']; echo "</li><ul>"; $stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$ref_id'"); $child_count = $stmt->rowCount(); while($child = $stmt->fetch(PDO::FETCH_LAZY)){ echo "<li>"; echo $child['acct_name']; $ref_ids = $child['ref_id']; echo "</li>"; } //$reff = "F7788"; //$stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$F7788'"); $stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$ref_ids'"); $child_count2 = $stmt->rowCount(); while($children = $stmt->fetch(PDO::FETCH_LAZY)){ echo "<ul><li>"; echo $children['acct_name']; echo "</li></ul>"; } Edited by Mr-Chidi, 25 December 2014 - 05:34 AM. Hello, I have a PHP page (below) that is suppose to update a field in my database. For some reason it does not update. I am trying to echo that sql with this script. Any help would be greatly appreciated. Thanks JR Code: [Select] $p = (100-$_POST[$c])/100; $sql = "delete from products_groups where customers_group_id = ".$sppc['customers_group_id']; echo $sql; tep_db_query($sql); $sql = "insert into products_groups select '". $sppc['customers_group_id'] ."' as customers_group_id, ( " . $p . " * p.products_price) as customers_group_price, p.products_id from products p"; echo $sql; tep_db_query($sql); Below is the complete code, Code: [Select] <?php require('includes/application_top.php'); ?> <!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> <script language="javascript" src="includes/general.js"></script> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();"> <div id="popupcalendar" class="text"></div> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'template_top.php'); ?> <!-- header_eof //--> <?php if (isset($_POST['Update'])) { $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id"; $sppc_query = tep_db_query($sppc_query_raw); while( $sppc = tep_db_fetch_array( $sppc_query ) ) { if ($sppc["customers_group_name"] != "Retail"){ //$sppc['customers_group_id'] $c = "CG_".$sppc['customers_group_id']; $tmp = $_POST[$c]; if ($tmp != 0) { $p = (100-$_POST[$c])/100; tep_db_query("delete from products_groups where customers_group_id = ".$sppc['customers_group_id']); tep_db_query ("insert into products_groups select '". $sppc['customers_group_id'] ."' as customers_group_id, ( " . $p . " * p.products_price) as customers_group_price, p.products_id from products p"); } //if not 0 } //if not Retail } } ?> <!-- body //--> <table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo "Special Pricing Discount Setup"; ?></td> <td class="specialPrice" align="right"> </td> </tr> </table></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td valign="top"><table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" align="left"> <?php if (isset($_POST['Update'])) { echo "<center>Updated!</center>"; } ?> </td> </tr> <?php $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id"; $sppc_query = tep_db_query($sppc_query_raw); while( $sppc = tep_db_fetch_array( $sppc_query ) ) { ?> <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)"> <td class="dataTableContent" align="left"> <?php if ($sppc["customers_group_name"] != "Retail"){ echo $sppc["customers_group_name"]; } if (isset($_POST['Update'])) { if ($sppc["customers_group_name"] != "Retail"){ $c = "CG_".$sppc['customers_group_id']; $tmp = $_POST[$c]; echo " Current Discount is $tmp%" ; } } ?> </td> </tr> <?php } ?> </table></td> </tr> <tr> <td valign="top"> <form action="" method="post"> <table border="0" width="40%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText" align="left"> </td> <td> </td> </tr> <?php $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id"; $sppc_query = tep_db_query($sppc_query_raw); while( $sppc = tep_db_fetch_array( $sppc_query ) ) { if ($sppc["customers_group_name"] != "Retail"){ ?> <tr> <td class="smallText" align="left">Set New Percentage (%) Discount for <?=$sppc["customers_group_name"]?> :</td> <td><input name="CG_<?=$sppc['customers_group_id']?>" type="text" size="5" value="0"></td> </tr> <?php } } ?> <tr> <td colspan="2" align="center"><input type="submit" name="Update" value="Update"></td> </tr> </table> </form> </td> </tr> </table></td> <!-- body_text_eof //--> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> $lastfm = file_get_contents('http://www.last.fm/group/Rishloo/members'); $users = explode('" id="r4_', $lastfm); $users = explode('">', $users[1]); var_dump($users[0]); that is only echoing one ID http://www.last.fm/group/Rishloo/members 1 id for each member it should be echoing.. any idea why it isnt? $lastfm = file_get_contents('http://www.last.fm/group/Rishloo/members'); $grab_id=explode('" id="r4_', $lastfm); for($b=1; $b<count($grab_id); $b++){ $getid=explode('">', $grab_id[$b]); echo count($getid[0]); } that echos all 1's.. any help is appreciated.. thanks thanks This problem is existing on a few pages so I'll be in the clear if I can figure out to solve it on one page. Problem is on form submission its still echoing back that sortorder variable which makes it hard for it to compare on the success function to display the right message because the message should be good, bad1, bad2, ... . So is there anyway around that or do I need to do something on the client side of the form page. <?php // Include the database page require ('../inc/dbconfig.php'); if ( isset( $_POST['menuid'] ) ) { $menuid = (int)$_POST['menuid']; $query = "SELECT COUNT(sortorder) AS numOrder FROM `menuitems` WHERE `menu_id` = '".$menuid."'"; $result = mysqli_query ($dbc, $query); $row = mysqli_fetch_array( $result, MYSQL_ASSOC ); $sortorder = $row[ 'numOrder' ] + 1; echo $sortorder; } if (isset($_POST['submitmenuitem'])) { $menuid = mysqli_real_escape_string($dbc, $_POST['menuid']); $itemname = mysqli_real_escape_string($dbc, $_POST['itemname']); $itemurl = mysqli_real_escape_string($dbc, $_POST['itemurl']); $sortorder = mysqli_real_escape_string($dbc, $_POST['sortorder']); $contentpage = mysqli_real_escape_string($dbc, $_POST['contentpage']); $newscategory = mysqli_real_escape_string($dbc, $_POST['newscategory']); $application = mysqli_real_escape_string($dbc, $_POST['application']); $query = "SELECT * FROM `menuitems` WHERE (`itemname` = '".$itemname."') OR (`itemurl` = '".$itemurl."') OR (`contentpage_id` = '".$contentpage."') OR (`application_id` = '".$application."') OR (`newscategory_id` = '".$newscategory."') AND `menu_id` = '".$menuid."'"; $result = mysqli_query ( $dbc, $query ); // Run The Query $rows = mysqli_num_rows($result); if ($rows == 0) { $query = "INSERT INTO `menuitems` (menu_id, itemname, itemurl, sortorder, contentpage_id, newscategory_id, application_id, creator_id, datecreated, enabled) VALUES ('".$menuid."','".$itemname."','".$itemurl."','".$sortorder."','".$contentpage."', '".$newscategory."', '".$application."', 1, NOW(), 0)"; mysqli_query($dbc, $query); echo "good"; } else { $row = mysqli_fetch_array($result); if (($row['itemname'] == $itemname) && ($row['newscategory_id'] == $newscategory)) echo 'bad9'; elseif (($row['itemname'] == $itemname) && ($row['application_id'] == $application)) echo 'bad8'; elseif (($row['itemname'] == $itemname) && ($row['contentpage_id'] == $contentpage)) echo 'bad7'; elseif (($row['itemname'] == $itemname) && ($row['itemurl'] == $itemurl)) echo 'bad6'; elseif ($row['newscategory_id'] == $newscategory) echo 'bad5'; elseif ($row['application_id'] == $application) echo 'bad4'; elseif ($row['contentpage_id'] == $contentpage) echo 'bad3'; elseif ($row['itemurl'] == $itemurl) echo 'bad2'; elseif ($row['itemname'] == $itemname) echo 'bad1'; } } if (isset($_POST['deletemenuitem'])){ $menuitemID = (int)$_POST['menuitemID']; $query = "UPDATE `menuitems` SET `enabled` = '1' WHERE `id` = '".$menuitemID."' LIMIT 1"; mysqli_query($dbc,$query); } ?> hi all, I have a piece of code which I coded where it selects all there cars out of the database and shows them, well it is meant to: $getall = mysql_query("SELECT car, id FROM garage WHERE owner='$username'"); $gotall = mysql_fetch_object($getall); echo "$gotall->car - $gotall->id<br />"; Its meant to echo out all the cars which the user own, but for some reason its only echoing one car. Can anyone see why its only showing one car with the id not all the cars they own? Thanks. Hi, this is how I echo some results from my DB: Code: [Select] <?php if(mysql_num_rows($execute)>0){ do{ echo " " .$result['id_cliente']. " " .$result['company_name']. " " .$result['cliente_tel']. " " ; }while($result = mysql_fetch_assoc($execute)); }else{ echo " No customer found. " ; } ?> and this echoes the results in one paragraph. I need to print the results in rows...and I need help with that. :shy:Thanks I have stored some texts in the database associated with a variable name in my database ... I intend to use this in my site as global text using the variable name ... This is the code I've created in a php file, which I'm 'including' in my webpage . <div style="display:none"> <?php mysqli_select_db($xxx, $database_xxx); $query_Recordset1 = "SELECT * FROM text_declares"; $Recordset1 = mysqli_query($xxx, $query_Recordset1) or die(mysqli_error()); $row_Recordset1 = mysqli_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysqli_num_rows($Recordset1); ?> <?php do { echo '$' . $row_Recordset1['bd_variable'] . ' = "' . $row_Recordset1['bd_desc'] . '"<br>'; } while ($row_Recordset1 = mysqli_fetch_assoc($Recordset1)); echo 'Company Name =' . $company_full_name ; ?> </div> When i execute the file, this is the ouput Quote
$company_full_name = "Some Company Pvt. Ltd." not able to figure out why the $company_full_name is not showing in the echo. Many Thanks for the support . Hi, I'm trying to echo some error message like this: Code: [Select] <?php echo (isset($_GET['failed']))?'.CNT_TXT_MYERRORMESSAGE.''; ?> i know it must be a syntax error....but I'm a newb.... Thanks Hi all, On my website I have a Functions file which holds information about the user for the game, but earier on today I added ranks which are for the users money. So for the ammout of money they have gives them a different money rank. Heres what ive got: function wealthrank(){ if (($info->money >= "0") && ($info->money < "10000")){ $wealth = "Poor (£0 - £10,000)"; $done="1"; } elseif (($info->money >= "10000") && ($info->money < "500000")){ $wealth = "Won The Lottery (£10,000- £500,000)"; $done="1"; } elseif (($info->money >= "500000") && ($info->money < "5000000")){ $wealth = "Too Much (£500,000 - £5,000,000)"; $done="1"; } elseif (($info->money >= "5000000") && ($info->money < "20000000")){ $wealth = "Millionare (£5,000,000 - £20,000,000)"; $done="1"; } elseif (($info->money >= "20000000") && ($info->money < "75000000")){ $wealth = "Owns The Streets (£20,000,000 - £75,000,000)"; $done="1"; } elseif (($info->money >= "75000000") && ($info->money < "100000000")){ $wealth = "Won The Euro Millions (£75,000,000 - £100,000,000)"; $done="1"; } elseif (($info->money >= "100000000") && ($info->money < "300000000")){ $wealth = "Multi millionare (£100,000,000 - £300,000,000)"; $done="1"; } elseif (($info->money >= "300000000") && ($info->money < "700000000")){ $wealth = "Owns A Bank (£300,000,000 - £700,000,000)"; $done="1"; } elseif (($info->money >= "700000000") && ($info->money < "1500000000")){ $wealth = "Rather Rich (£700,000,000 - £1,500,000,000)"; $done="1"; } elseif (($info->money >= "1500000000") && ($info->money < "5000000000")){ $wealth = "Billionare (£1,500,000,000 - £5,000,000,000)"; $done="1"; } elseif (($info->money >= "5000000000") && ($info->money < "70000000000")){ $wealth = "Owner Of The Land (£5,000,000,000 +)"; $done="1"; } elseif ($info->money >= "100000000000"){ $wealth = "Nearly As Rich As NoName (Hidden!)"; $done="1"; } if (!$done){ $done="0"; } if ($done == "1"){ mysql_query("UPDATE users SET wealthrank='$wealth' WHERE username='$username'"); }} wealthrank(); For some reason its not echoing the correct wealth rank, even at that its only echoing the defult wealth rank. Here is what I done to test it. <?php session_start(); include ("includes/functions.php"); include ("includes/config.php"); logincheck(); $username = $_SESSION['username']; $get = mysql_query ("SELECT * FROM users WHERE username='$username'"); $fetch = mysql_fetch_object($get); ?> Testing something: <?php echo ($username); ?><br /> Wealth Rank: <?php echo ($fetch->wealthrank); ?><br /> Is there something wrong with the way im fetching it from the Database or something wrong with the code? Thanks for any help given. Hi all, I have this code which is suppose to display everymessage that the User has, but when im trying to display the messages its displaying them all in different tables.. Im trying to get it so it will be like: inbox ------------------ subject | From subject | username Read Messages ------------------ subject | From subject | username So two tables which one displays the messages which havent been read while the other does <?php session_start(); include "includes/config.php"; include "includes/functions.php"; logincheck(); ini_set ('display_errors', 1); error_reporting (E_ALL); $user=$_SESSION['username']; // Grab whats needed... $all_msgs = mysql_query("SELECT `id` FROM `inbox` WHERE `to`='$user' ORDER BY `id` DESC") or die("Error on line 9 - " . mysql_error()); $get_msg = mysql_query("SELECT * FROM `inbox` WHERE `to`='$user' ORDER BY `id` DESC") or die("Error on line 10 - " . mysql_error()); $msg_num = mysql_num_rows($all_msgs); // lets echo the subject + A linking to the message... echo '<table width="50%" cellpadding="0" align="center" cellspacing="0" border="1" class="table"> <tr> <td class="header" algin="center" colspan="2">Inbox</td> </tr> <tr> <td class="omg" align="center">Subject</td><td align="center" class="omg">From</td> </tr>'; for($number = 1; $number <= $msg_num; $number++) { $line = mysql_fetch_array($get_msg); //if the message is not read... if($line['read'] == 0){ echo '<tr> <td width="50%" align="center"><a href="rmessage.php?messageid=' . $line['id'] . '">' . $line['title'] . '</a>(New)</td><td width="50%" align="center"><a href="profile.php?viewuser=' . $line['from'] . '">' . $line['from'] . '</a></td> </tr></table> <br /> <br />'; }else{ // If message is read... echo '<br /><table width="50%" cellpadding="0" align="center" cellspacing="0" border="1" class="table"> <tr> <td class="header" algin="center" colspan="2">Messages Read</td> </tr> <tr> <td class="omg" align="center">Subject</td><td class="omg" align="center">From</td></td> </tr> <tr> <td width="50%" align="center"><a href="rmessage.php?messageid=' . $line['id'] . '">' . $line['title'] . '</a></td><td width="50%" align="center"><a href="profile.php?viewuser=' . $line['from'] . '">' . $line['from'] . '</td> </tr></table>'; }} ?> Anyone see a way I can sort it so it don't show a table for every message they have? Thanks for any help given I am probably making a dumb mistake...but heres the code... $gif = '.gif'; $jpg = '.jpg'; $jpeg = '.jpeg'; $png = '.png'; $jpeg1 = 'jpeg'; $gif1 = 'gif'; $jpg1 = 'jpg'; $png1 = 'png'; $max_file_size = '1048576'; $new_avatar = $_FILES['uploaded_avatar']['name']; $avatar_ext = end(explode('.', $new_avatar)); if (isset($_POST['change_submit1'])) { if ($_SESSION['logged_in'] != '1') { echo 'You need to be logged in!'; } elseif ($_POST['change_box1'] != 'CHANGE') { echo 'You must fill in the "CHANGE" box!'; } elseif (($uploaded_a_file == '1') && ($avatar_ext != $jpg1) && ($avatar_ext != $png1) && ($avatar_ext != $gif1) && ($avatar_ext != $jpeg1)) { echo 'File format not supported!'; } elseif ($uploaded_a_file != '1') { echo 'No file selected!'; } elseif ($_FILES["uploaded_avatar"]["size"] > $max_file_size) { echo 'File is too big!'; } } this is the code that should be echoing my avatar upload errors. Ive checked all the if statements ive changed the order around. still nothing. all of them work other than file format not supported. I can get this one to work...but at the cost of no file selected not working...help! Folks, I want to echo an HTML tag in PHP. Code: [Select] <td width="300" bgcolor="#ffffff" align="center" onmouseout="style.backgroundColor='#ffffff'" onmouseover="style.backgroundColor='#e8e8e8';" style="word-wrap: break-word; border: 1px solid rgb(238, 238, 238); font-size: 12px; background-color: rgb(255, 255, 255);"> So what i am doing is; Code: [Select] echo '<td width="300" bgcolor="#ffffff" align="center" onmouseout="style.backgroundColor='#ffffff'" onmouseover="style.backgroundColor='#e8e8e8';" style="word-wrap: break-word; border: 1px solid rgb(238, 238, 238); font-size: 12px; background-color: rgb(255, 255, 255);">'; And its now working because this tag already has ' (Single Quotes) & ; (Semicolon) so its conflicting. Any work around for this friends? Cheers N I want to echo the contents of column 4 for my username only, and it doesn't show anything. I can do if ($memberQuery->fetchColumn(4) < 2)() though. Code: [Select] $host = 'localhost'; $database = ''; $db_username = ''; $db_password = ''; if (($db = new PDO("mysql:host=$host;dbname=$database", $db_username, $db_password)) == NULL) { echo $db->getMessage(); } $memberQuery = $db->prepare("SELECT * FROM members WHERE username=:username"); $memberQuery->execute(array(':username' => $_SESSION['username'])); $result = $memberQuery->fetchColumn(4); echo "$result"; how do i echo "checked=checked" for a checkbox? here is what i have: Code: [Select] <input type='checkbox' name='ip_automatic_login' id='ip_automatic_login' value='1' if($IPCheck == true) {/"checked=checked/" } /> this code will be echoed! I have a login form at http://cloydprojects.com you can login with username: test password test If you login the script works correctly, but if you type in the wrong info my session is not showing here is that I have. my login script Code: [Select] <?php session_start(); ?> <link href="signUp.css" rel="stylesheet" type="text/css" /> <?php include("db.php"); include("classes/class.account.php"); $Acc = new account; $u = $Acc->clean($_REQUEST['usernameLogin']); $password = $Acc->clean($_REQUEST['passwordLogin']); $p = md5($password); $get = mysql_query("SELECT * FROM users WHERE username = '".$u."' and password = '".$p."'"); $find = mysql_num_rows($get); if ($find == 1) { $info = mysql_fetch_assoc($get); $_SESSION['LoggedIn'] = $info['uID'].'.'.$info['username'].'.'.$info['email']; } else { $_SESSION['LoggedFailed'] = '<div id="ErrorBox">Incorrect username/password!</div>'; } //there is more just not showing it here is my index script where the error should be showing! Code: [Select] <div class="stylized"> <?php if(isset($_SESSION['LoggedIn'])) { echo '<h1> Welcome! </h1>'; echo '<a href="logout.php">logout!</a>'; } else { echo $_SESSION['LoggedFailed']; session_destroy(); ?> <form id="instantform" name="form" action="loginUser.php" method="post"> <h1>Login</h1> <label>Username <span class="small">The username you created!</span></label> <input type="text" name="usernameLogin" id="usernameLogin" /> <label>Password <span class="small">Case sensitive!</span></label> <input type="password" name="passwordLogin" id="passwordLogin" /> <button type="submit">Login</button></div> <div class="spacer"></div> </form> <?php } ?> </div> |