Jump to content

bpburrow

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bpburrow's Achievements

Member

Member (2/5)

0

Reputation

  1. If anyone's interested I had to add a value to the button tag. Don't know why, didn't think it was necessary considering the format I was using. Here's my new button: <button class="primary_lg right" title="Sign in" type="submit" name="submit" value="Sign in">Sign in</button>
  2. Need help figuring out why my button tag isn't working. If I use the standard input tag, <input type="submit" name="submit" value="Sign in" />, I have no issues. However, I want to use <button type="submit" name="submit" class="primary_lg right">Sign in</button> to dress it up a bit. Problem is, even though variables are being passed, it doesn't pull up my main admin page. In short, I want this which doesn't work: <button type="submit" name="submit" class="primary_lg right">Sign in</button> instead of this which does work: <input type="submit" name="submit" value="Sign in" /> Both pass variables, however the <button> doesn't load the follow-on page (mainadmin.php). Here's my script: <?php if(!$_POST['submit']){ // 'submit' hasn't been clicked so output html.?> <form action="admin_login2.php" method="post"> <fieldset> <div style="float:right;"><a href="/SSP/ssp_director/index.php?/users/password" title="Click here to retrieve login" class="mute">Lost username?</a></div> <label for="username">Username:</label> <input id="username" type="text" name="username" class="wide" value="" /> </fieldset> <fieldset> <label for="password">Password:</label> <input type="password" name="password" class="wide" value="" /> </fieldset> <fieldset> <button type="submit" name="submit" class="primary_lg right">Sign in</button> <input type="submit" name="submit" value="Sign in" /> </fieldset> </form> <?php }else{ $user= protect($_POST['username']); $pass= protect($_POST['password']); if($user && $pass){ $pass = md5($pass); //compare the encrypted password $sql="SELECT id,username FROM Admin WHERE username='$user' AND password='$pass'"; $query=mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($query) > 0){ $row = mysql_fetch_assoc($query); // mysql_fetch_assoc gets the value for each field in the row $_SESSION['id'] = $row['id']; //creates the first session var $_SESSION['username'] = $row['username']; // second session var echo "<script type=\"text/javascript\">window.location=\"mainadmin.php\"</script>"; }else{ //I added $user, $pass to see the forms output. Output was same as db. echo "<script type=\"text/javascript\"> alert(\"Username and password combination is incorrect!\"); window.location=\"admin_login2.php\"</script>"; } }else{ //this script works fine when I leave a field empty echo "<script type=\"text/javascript\"> alert(\"You need to gimme a username AND password!\"); window.location=\"admin_login2.php\"</script>"; } } ?>
  3. Last month I was crawling. Today I feel like I'm standing. Thanks for the help. Makes a lot of sense!! I had to change <?php $folder=mysql_result($res, 0, 0); $image=mysql_result($res, 1, 0); ?> with <?php $folder=mysql_result($res, 0, "foldername"); $image=mysql_result($res, 0, "image_name"); ?> Everything seems to be working fine. I'll close this post once I'm sure all the bugs have been worked out. Thanks again!! Here's the script if anyone's interested. <?php // If 'delbtn' clicked then delete row, folder and image then show new slideshow listing. if(isset($_POST['delbtn'])){ // Loop through check boxes foreach($_POST['deletes'] as $id){ $res = mysql_query("SELECT foldername, image_name FROM Slideshow WHERE slide_id='$id'"); $folder=mysql_result($res, 0, "foldername"); $image=mysql_result($res, 0, "image_name"); $folderPath = implode(DIRECTORY_SEPARATOR, array('..','client', $folder)); $imagePath = implode(DIRECTORY_SEPARATOR, array('..','client_images', $image)); // Delete folder and contents. if (!is_dir($folderPath)) { echo 'Folder path does not exist. '; }else{ rmdir($folderPath) or die( "Unable To Delete Folder. Please Try Again Later" ); } // Delete client image. if(!is_file($imagePath)){ echo 'Client image path does not exist'; }else{ unlink($imagePath) or die( "Unable To Delete File. Please Try Again Later" ); } // Delete row from database mysql_query("DELETE FROM Slideshow WHERE slide_id='$id'"); } } // SQL query $query="SELECT * FROM Slideshow"; $result=mysql_query($query) or die('Query failed: ' . mysql_error()); // Get number of rows $num_rows = mysql_num_rows($result); // Error message for empty DB else show results if ($num_rows == 0){ $errors[] = "Database does not contain slideshow listings!<br /><br /> <button type=\"submit\" onClick=\"location.href='slideshow_new.php'\">Add Slideshow</button>"; } else { ?> <form action="slideshow_list.php" method="post" class="clearfix"> <fieldset class="clearfix"> <legend> Slideshow List </legend> <?php // Print results in HTML // Number of records echo "<p class=\"indent\">Slideshow count = $num_rows</p>\n"; ?> <table border="0" cellpadding="4" cellspacing="4" align="center"> <tr> <th align=center>Delete</th> <th>ID</th> <th>Username</th> <th>Folder</th> <th>Active</th> <th>Date</th> <th>Image</th> </tr> <?php while($row=mysql_fetch_array($result)){?> <tr> <td align=center><input type="checkbox" name= <?php echo "deletes[]" ?> id= <?php echo $row['slide_id'] ?> value=<?php echo $row['slide_id'] ?> /></td> <td><?php echo $row['slide_id'] ?></td> <td><?php echo $row['username'] ?></td> <td><?php echo $row['foldername'] ?></td> <td align="center"><?php echo $row['active'] ?></td> <td><?php echo $row['session_date'] ?></td> <td><?php echo $row['image_name'] ?></td> </tr> <?php } ?> <tr> <td><input class="delete" type="submit" name="delbtn" value="Delete" /></td> </tr> </table> </fieldset> </form> <?php } if(count($errors) > 0){ ?> <fieldset class="clearfix"> <legend>Errors</legend> <?php echo "<div class=\"indent\"><br /><p class=\"bodyText\">The following errors have occured:</p></div>"; echo "<div class=\"indent\"><p class=\"error\">"; foreach($errors AS $error){ echo $error . "\n"; } echo "</p></div>"; } //close DB mysql_close(); ?>
  4. I mispoke when I said I got nothing from echoing $folder and $image. What I'm getting is foldername and image_name. Hard coding is not my intent. I want to select 'foldername' and 'image_name' values from the db according to the selected id.
  5. This administrator page displays a list of client slideshows with a delete checkbox at the beginning of each row. Upon submission the script deletes the folder containing the slideshow, deletes an image in a different folder, and removes the record from the database; then it reloads itself showing the current listings. I'm having a problem deleting the folder and image. I think the problem is happening with the $folder and $image variable assignments. To test it I tried to echo $folder and $image and got nothing which would explain why I'm getting errors with paths not existing. I'm sure the answer's right there in front of me, I'm just not seeing it. Thanks in advance. <?php // If 'delbtn' clicked then delete row, folder and image then show new slideshow listing. if(isset($_POST['delbtn'])){ // Loop through check boxes foreach($_POST['deletes'] as $id){ mysql_query("SELECT FROM SLIDESHOW foldername, image_name WHERE slide_id='$id'"); $folder='foldername'; $image='image_name'; $folderPath = implode(DIRECTORY_SEPARATOR, array('..','client','$folder')); $imagePath = implode(DIRECTORY_SEPARATOR, array('..','client_images','$image')); echo $folder; echo $image_name; // Delete folder and contents. if (!is_dir('$folderPath')) { echo 'Folder $folder does not exist. '; }else{ rmdir("$folderPath") or die( "Unable To Delete Folder. Please Try Again Later" ); } // Delete client image. if(!is_file("$imagePath")){ echo 'Client image $image does not exist'; }else{ unlink("$image") or die( "Unable To Delete File. Please Try Again Later" ); } // Delete row from database mysql_query("DELETE FROM Slideshow WHERE slide_id='$id'"); } } // SQL query $query="SELECT * FROM Slideshow"; $result=mysql_query($query) or die('Query failed: ' . mysql_error()); // Get number of rows $num_rows = mysql_num_rows($result); // Error message for empty DB else show results if ($num_rows == 0){ $errors[] = "Database does not contain slideshow listings!<br /><br /> <button type=\"submit\" onClick=\"location.href='slideshow_new.php'\">Add Slideshow</button>"; } else { ?> [code] Here's the entire code if you're interested. [code] <?php // If 'delbtn' clicked then delete row, folder and image then show new slideshow listing. if(isset($_POST['delbtn'])){ // Loop through check boxes foreach($_POST['deletes'] as $id){ mysql_query("SELECT FROM SLIDESHOW foldername, image_name WHERE slide_id='$id'"); $folder='foldername'; $image='image_name'; $folderPath = implode(DIRECTORY_SEPARATOR, array('..','client','$folder')); $imagePath = implode(DIRECTORY_SEPARATOR, array('..','client_images','$image')); echo $folder; echo $image_name; // Delete folder and contents. if (!is_dir('$folderPath')) { echo 'Folder $folder does not exist. '; }else{ rmdir("$folderPath") or die( "Unable To Delete Folder. Please Try Again Later" ); } // Delete client image. if(!is_file("$imagePath")){ echo 'Client image $image does not exist'; }else{ unlink("$image") or die( "Unable To Delete File. Please Try Again Later" ); } // Delete row from database mysql_query("DELETE FROM Slideshow WHERE slide_id='$id'"); } } // SQL query $query="SELECT * FROM Slideshow"; $result=mysql_query($query) or die('Query failed: ' . mysql_error()); // Get number of rows $num_rows = mysql_num_rows($result); // Error message for empty DB else show results if ($num_rows == 0){ $errors[] = "Database does not contain slideshow listings!<br /><br /> <button type=\"submit\" onClick=\"location.href='slideshow_new.php'\">Add Slideshow</button>"; } else { ?> <form action="slideshow_list.php" method="post" class="clearfix"> <fieldset class="clearfix"> <legend> Slideshow List </legend> <?php // Print results in HTML // Number of records echo "<p class=\"indent\">Slideshow count = $num_rows</p>\n"; ?> <table border="0" cellpadding="4" cellspacing="4" align="center"> <tr> <th align=center>Delete</th> <th>ID</th> <th>Username</th> <th>Folder</th> <th>Active</th> <th>Date</th> <th>Image</th> </tr> <?php while($row=mysql_fetch_array($result)){?> <tr> <td align=center><input type="checkbox" name= <?php echo "deletes[]" ?> id= <?php echo $row['slide_id'] ?> value=<?php echo $row['slide_id'] ?> /></td> <td><?php echo $row['slide_id'] ?></td> <td><?php echo $row['username'] ?></td> <td><?php echo $row['foldername'] ?></td> <td align="center"><?php echo $row['active'] ?></td> <td><?php echo $row['session_date'] ?></td> <td><?php echo $row['image_name'] ?></td> </tr> <?php } ?> <tr> <td><input class="delete" type="submit" name="delbtn" value="Delete" /></td> </tr> </table> </fieldset> </form> <?php } if(count($errors) > 0){ ?> <fieldset class="clearfix"> <legend>Errors</legend> <?php echo "<div class=\"indent\"><br /><p class=\"bodyText\">The following errors have occured:</p></div>"; echo "<div class=\"indent\"><p class=\"error\">"; foreach($errors AS $error){ echo $error . "\n"; } echo "</p></div>"; //we use javascript to go back rather than reloading the page // so the user doesn't have to type in all that info again. } //close DB mysql_close(); ?>
  6. Here's a sight that's been helping me get started. http://www.free-css.com/free-css-resources.php
  7. I had a comment before " @charset "UTF-8" " in my CSS. Apparently that's a no no. It's interesting that firefox ignored the error.
  8. So I've spent the last year or so learning the basics of html, css, php and mysql while all along building a website. This week I decided to go back and clean up all patch work and various types of styles and methods. I created dummy pages while making changes just in case I screwed things up. It's a good thing I did. Apparently I didn't learn enough. Can anyone tell me why my css is working just fine in Firefox, but doesn't work at all in Safari or Chrome. www.brittanyburrowphotography.com/index2.php
  9. Because it's been a long day and I'm in desperate need of sleep. Your fix worked!! Thanks to all who helped. Here's the finished script if anyone wants to see: <div id="col3_content" class="clearfix"> <form action="client_list.php" action="slideshow_new.php" method="post" class="clearfix"> <fieldset class="clearfix"> <legend> Client List </legend> <?php // SQL query $query="SELECT * FROM Client"; $result=mysql_query($query) or die('Query failed: ' . mysql_error()); $num_rows = mysql_num_rows($result); // Error message for empty DB if ($num_rows == 0){ $errors[] = "Database contains no client records.<br /> <div class=\"bodyText\"><a href=\"../admin/client_new.php\">Add Client</a></div>"; } else { // Print results in HTML // Number of records $num_rows = mysql_num_rows($result); echo "<p class=\"indent\">Client count = $num_rows</p>\n"; ?> <table border="0" cellpadding="4" cellspacing="4" align="center"> <tr> <th align=center>Delete</th> <th>ID</th> <th>Firstname</th> <th>Lastname</th> <th>Username</th> <th>Email</th> </tr> <?php while($row=mysql_fetch_array($result)){ ?> <tr> <td align=center><input type="checkbox" name= <?php echo "deletes[]" ?> id= <?php echo $row['client_id'] ?> value=<?php echo $row['client_id'] ?> /></td> <td><?php echo $row['client_id'] ?></td> <td><?php echo $row['firstName'] ?></td> <td><?php echo $row['lastName'] ?></td> <td><?php echo $row['username'] ?></td> <td><?php echo $row['email'] ?></td> </tr> <?php } ?> <td><input class="delete" type="submit" name="delbtn" value="Delete" /></td> </table> <?php } ?> </fieldset> </form> <?php if(isset($_POST['delbtn'])) { // Loop through check boxes foreach($_POST['deletes'] as $id){ // Delete record from database mysql_query("DELETE FROM Client WHERE client_id='$id'"); } } if(count($errors) > 0){ echo "<fieldset><legend>Errors</legend>"; echo "<div class=\"indent\"><br /><p class=\"bodyText\">The following errors occured with your client:</p></div><br />"; echo "<div class=\"indent\"><p class=\"error\">"; foreach($errors AS $error){ echo $error . "\n"; } echo "</p></div>"; //we use javascript to go back rather than reloading the page // so the user doesn't have to type in all that info again. } //close DB mysql_close(); ?> </div>
  10. Well that's embarrasing. I fixed the contents problem. However, the page still isn't reloading on Delete. <table border="0" cellpadding="4" cellspacing="4" align="center"> <tr> <th align=center>Delete</th> <th>ID</th> <th>Firstname</th> <th>Lastname</th> <th>Username</th> <th>Email</th> </tr> <?php while($row=mysql_fetch_array($result)){ ?> <tr> <td align=center><input type="checkbox" name= <?php echo "deletes[]" ?> id= <?php echo $row['client_id'] ?> value=<?php echo $row['client_id'] ?> /></td> <td><?php echo $row['client_id'] ?></td> <td><?php echo $row['firstName'] ?></td> <td><?php echo $row['lastName'] ?></td> <td><?php echo $row['username'] ?></td> <td><?php echo $row['email'] ?></td> </tr> <?php } ?> <td><input class="delete" type="submit" name="delbtn" value="Delete" onclick="document.location = '../admin/client_list.php';"/></td> </table>
  11. I made the changes, however, the variables aren't passing info to the table. I'm guessing syntax errors. Here's the section of table having issues. <table border="0" cellpadding="4" cellspacing="4" align="center"> <tr> <th align=center>Delete</th> <th>ID</th> <th>Firstname</th> <th>Lastname</th> <th>Username</th> <th>Email</th> </tr> <?php while($row=mysql_fetch_array($result)){ ?> <tr> <td align=center><input type="checkbox" name= <?php "deletes[]" ?> id= <?php $row['client_id'] ?> value=<?php $row['client_id'] ?> /></td> <td><?php $row['client_id'] ?></td> <td><?php $row['firstName'] ?></td> <td><?php $row['lastName'] ?></td> <td><?php $row['username'] ?></td> <td><?php $row['email'] ?></td> </tr> <?php } ?> <tr> <td><input class="delete" type="submit" name="delbtn" value="Delete" onclick="document.location = '../admin/client_list.php';"/></td> </tr> </table>
  12. That's a pretty cool trick. Definately something I'll keep in my back pocket. The problem was in the mysql query. I had <?php mysql_query("DELETE FROM Client WHERE id='$id'");?> vice <?php mysql_query("DELETE FROM Client WHERE client_id='$id'"); ?> Next, how do I go about reloading the page without using header('Location: ../some.php/');? The header function seem to conflict with a number of included/required .php files. I thought about using JS onClick for the delete button but then the page would be redirected without completing the script to delete rows. Any suggestions??
  13. I didn't show entire script on last post. Here's what I have with recommended changes. Still having the same problem. <form action="client_list.php" method="post" class="clearfix"> <fieldset class="clearfix"> <legend> Client List </legend> <?php // SQL query $query="SELECT * FROM Client"; $result=mysql_query($query) or die('Query failed: ' . mysql_error()); $num_rows = mysql_num_rows($result); // Error message for empty DB if ($num_rows == 0){ $errors[] = "Database contains no client records.<br /> <div class=\"bodyText\"><a href=\"../admin/client_new.php\">Add Client</a></div>"; } else { // Print results in HTML // Number of records $num_rows = mysql_num_rows($result); echo "<p class=\"indent\">Client count = $num_rows</p>\n"; echo "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\" align=\"center\"> <tr> <th align=center>Delete</th> <th>ID</th> <th>Firstname</th> <th>Lastname</th> <th>Username</th> <th>Email</th> </tr>\n"; while($row=mysql_fetch_array($result)) { echo "<tr>\n"; echo "\n<td align=center><input type=\"checkbox\" name=\"deletes[]\" id=\"". $row['client_id'] . "\" value=\"". $row['client_id'] . "\" /></td>"; echo "\n<td>". $row['client_id'] . "</td>"; echo "\n<td>". $row['firstName'] . "</td>"; echo "\n<td>". $row['lastName'] . "</td>"; echo "\n<td>". $row['username'] . "</td>"; echo "\n<td>". $row['email'] . "</td>"; echo "\n</tr>"; } echo "\n<td><input class=\"delete\" type=\"submit\" name=\"delbtn\" value=\"Delete\" /></td>"; echo "\n</table>\n"; } ?> </fieldset> </form> <?php if(isset($_POST['delbtn'])) { // Loop through check boxes foreach ($_POST['deletes'] as $id){ // Delete record from database mysql_query("DELETE FROM Client WHERE id='$id'"); } } if(count($errors) > 0){ echo "<fieldset><legend>Errors</legend>"; echo "<div class=\"indent\"><br /><p class=\"bodyText\">The following errors occured with your client:</p></div><br />"; echo "<div class=\"indent\"><p class=\"error\">"; foreach($errors AS $error){ echo $error . "\n"; } echo "</p></div>"; //we use javascript to go back rather than reloading the page // so the user doesn't have to type in all that info again. } //close DB mysql_close(); ?>
  14. I scrapped my previous table and decided to start over. How that the html formatting is out of the way I'm stuck on the delete action. Rows aren't being deleted after pressing button. <?php // SQL query $query="SELECT * FROM Client"; $result=mysql_query($query) or die('Query failed: ' . mysql_error()); $num_rows = mysql_num_rows($result); // Error message for empty DB if ($num_rows == 0){ $errors[] = "Database contains no client records.<br /> <div class=\"bodyText\"><a href=\"../admin/client_new.php\">Add Client</a></div>"; } else { // Print results in HTML // Number of records $num_rows = mysql_num_rows($result); echo "<p class=\"indent\">Client count = $num_rows</p>\n"; echo "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\" align=\"center\"> <tr> <th align=center>Delete</th> <th>ID</th> <th>Firstname</th> <th>Lastname</th> <th>Username</th> <th>Email</th> </tr>\n"; while($row=mysql_fetch_array($result)) { echo "<tr>\n"; echo "\n<td align=center><input type=checkbox name=". $row['client_id'] . " id=". $row['client_id'] . " value=". $row['client_id'] . " /></td>"; echo "\n<td>". $row['client_id'] . "</td>"; echo "\n<td>". $row['firstName'] . "</td>"; echo "\n<td>". $row['lastName'] . "</td>"; echo "\n<td>". $row['username'] . "</td>"; echo "\n<td>". $row['email'] . "</td>"; echo "\n</tr>"; } echo "\n<td><input class=\"delete\" type=\"submit\" name=\"delbtn\" value=\"Delete\" /></td>"; echo "\n</table>\n"; } $id= $_POST["client_id"]; if(isset($_POST['delbtn'])) { // Loop through check boxes foreach($_POST as $id) { // Delete record from database mysql_query("DELETE FROM Client WHERE id='$id'"); } } if(count($errors) > 0){ echo "<div class='error'>"; foreach($errors AS $error){ echo $error . "<br />"; } echo "</div>"; echo "<div class=\"bodyText\"><a href=\"../admin/client_new.php\">Add Client</a></div>"; //we use javascript to go back rather than reloading the page // so the user doesn't have to type in all that info again. } //close DB mysql_close(); ?>
  15. The link appears after each field. How do I adjust so it only shows at the end of the rows? I added the following: <?php foreach ($line as $col_value){ echo "\t\t<td>$col_value<a href=\"delete.php\">Delete</a></td>\n"; } ?> And this is what I've got: Client count = 4 client_id firstName lastName username passwd email 10Delete janeDelete doeDelete test1Delete 5a105e8b9d40e1329780Delete test1@hotmail.comDelete
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.