Search the Community
Showing results for tags 'php coding help'.
-
<html> <body> <form method="post" action=""> Username:<input type="text" name="user"> password:<input type="text" name="pass"> <input type="submit" name="submit" value="submit"> </form> </body> </html> <?php $user=$_POST['user']; $pass=$_POST['pass']; $conn = mysql_connect("localhost","root","root"); if ($conn): $selectDB=mysql_select_db("project",$conn); if (!$selectDB): echo mysql_error(); endif; endif; // how many rows to show per page $rowsPerPage = 2; // by default we show first page $pageNum = 1; // if $_GET['page'] defined, use it as page number if(isset($_GET['page'])) { $pageNum = $_GET['page']; } // counting the offset $offset = ($pageNum - 1) * $rowsPerPage; $query = "SELECT * FROM form1 LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die(mysql_error()); if(isset($_POST['submit'])){ if($user=="jishil" && $pass=="1234"){ // print the random numbers echo "FORM 1"; echo "<table width='50%' border='1'>"; echo "<tr><td>USERNAME</td><td>ADDRESS</td><td>COMPANY</td><td>SALARY</td><td>D.O.B</td><td>D.O.J</td></tr>"; while($rows=mysql_fetch_array($result)){ echo "<form action='' method='post'>"; echo "<tr>"; echo "<td>" . "<input type='text' name='Name' value=" . $rows['name']. " </td>"; echo "<td>" . "<input type='text' name='Address' value=" . $rows['address']. " </td>"; echo "<td>" . "<input type='text' name='Comp' value=" . $rows['comp']. " </td>"; echo "<td>" . "<input type='text' name='Sal' value=" . $rows['sal']. " </td>"; echo "<td>" . "<input type='text' name='Birth' value=" . $rows['birth']. " </td>"; echo "<td>" . "<input type='text' name='Join' value=" . $rows['join']. " </td>"; echo "<td>" . "<input type='hidden' name='hidden' value=" . $rows['name']. " </td>"; echo "<td>" . "<input type='submit' name='update' value=update" ." </td>"; echo "</tr>"; echo "</form>"; } echo "</table>"; // how many rows we have in database $query = "SELECT COUNT(name) AS numrows FROM form1"; $result = mysql_query($query) or die('Error, query failed'); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numrows = $row['numrows']; // how many pages we have when using paging? $maxPage = ceil($numrows/$rowsPerPage); // print the link to access each page $self = $_SERVER['PHP_SELF']; $nav = ''; for($page = 1; $page <= $maxPage; $page++) { if ($page == $pageNum) { $nav .= " $page "; // no need to create a link to current page } else { $nav .= " <a href=\"$self?page=$page\">$page</a> "; } } // creating previous and next link // plus the link to go straight to // the first and last page if ($pageNum > 1) { $page = $pageNum - 1; $prev = " <a href=\"$self?page=$page\">[Prev]</a> "; $first = " <a href=\"$self?page=1\">[First Page]</a> "; } else { $prev = ' '; // we're on page one, don't print previous link $first = ' '; // nor the first page link } if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " <a href=\"$self?page=$page\">[Next]</a> "; $last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> "; } else { $next = ' '; // we're on the last page, don't print next link $last = ' '; // nor the last page link } // print the navigation link echo $first . $prev . $nav . $next . $last; }} ?>
-
I have a database that has as a field `businessname`. I do a number of things with this field that are working fine, like populating textboxes, printing out as echo in any number of uses (<?php echo Recordset1['businessname'] ?>). But for some reason when I try to echo in precisely the same fashion in an automated gmail all I get is "Pete's Coffee" and none of the subsequent text that normally accompanies the name of the business appears. I know that the & is a special character but just as I have no idea why it is causing an error to be thrown, I can't understand why it appears fine in others. Given that the string resides in fine shape in the database (with apostrophe and ampersand intact) is there something I can do to sanitize the string when retreived by a query so it can be used in all applications? Any help will be appreciated. Jim
-
Hello to all, and thanks for any advice you can offer. I am kinda ole skool when it comes to web design. I've been working with HTML for a while, but not familiar with php. I am trying to redesign my site using more php. I am learning the code just by reading and studying articles and tutorials on the web. I have a few things working ok, but I am struggling with the following error message: "Warning: include(./pages/index.php): failed to open stream: No such file or directory in /www/dillardhigh.com/html/dca/main/index.php on line 156 Warning: include(./pages/index.php): failed to open stream: No such file or directory in /www/dillardhigh.com/html/dca/main/index.php on line 156 Warning: include(): Failed opening './pages/index.php' for inclusion (include_path='.:/usr/lib64/php') in /www/dillardhigh.com/html/dca/main/index.php on line 156" I am assuming this is some type of path issue, but I can't seem to figure out how to resolve it. I have tried several different paths that I thought would work, but I get the same error. Can anyone see something in this that I might be overlooking? Thanks for your help!