Jump to content

iraisis

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Female
  • Location
    Germany

iraisis's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes! All works now! I ended up putting an include in the function as well as at the bottom of the page. All i was missing before was putting the exit() in the right place. I couldn't seem to get this working with variables though. Tried making a variable and then echoing it out instead of using two includes: $footer = include_once('inc/footer.inc.php'); //and then in the right places: echo $footer; But alas, my problems are solved. Thanks a bunch.
  2. Ha! Well that certainly brings my footer back but sadly then the page doesn't work because the edit section is then not hiding before an event is selected. I hope you see what I mean. Is there another way of doing this?
  3. Thanks again for you help. I have pretty much finished my little CMS, although I am encountering a frustrating problem. The script I'm using is ignoring the HTML in the bottom firsthand which means my footer is missing. As you can see I have tried to echo it with a function but have not succeeded: How can I get my footer back? Here is my reduced code: <? include('connect.php'); //Injection preventation and global variables to easier names. $id = mysql_escape_string($_POST["id"]); $date = mysql_escape_string($_POST["date"]); $name = mysql_escape_string($_POST["name"]); $text =mysql_escape_string($_POST["text"]); ?> <html> <head> <link rel="stylesheet" href="#.css" type="text/css"></link> </head> <body> <div id="content"> <h2>Manage events</h2> <div class="edit_section"> <h4>Click on an event to edit or delete it or <a href="new.php"><input type="button" name="new" value="Add an Event"/></a> here.</h4> <?php // Script EDITS and DELETES events if ($_GET["action"] == "edit") { $query=mysql_query("SELECT * FROM events WHERE id='".$_GET["id"]."'"); if ($query) { $row=mysql_fetch_array($query); echo "You are editing event \"".$row["name"]." \". <br><br>"; } else editNews(); footer(); } elseif ($_POST["action"] == "delete") { $query=mysql_query("DELETE FROM events WHERE id='".$id."'"); if ($query) echo "The record was successfully deleted. <br><br>"; else echo "Failed to delete the record <br><br>"; editNews(); footer(); } elseif ($_POST["action"] == "doedit") { $query=mysql_query("UPDATE events SET date='".$date."', name='".$name."', text='".$text."' WHERE id='".$id."' "); if ($query) echo "\"$name\" was successfully updated."; else echo "Failed to update $name."; editNews(); footer(); } else { editNews(); footer(); } //My failed attempt to include the footer at the bottom of the page. function footer() { include_once('inc/three.inc.php')/*This script ends the HTML page.*/; } // Echos out table for managing events: function editNews() { ?> <table width="600px"> <tr> <td width="5%"> # </td> <td width="45%">Event date info</td> <td width="50%">Event Titles:</td> </tr> <?php $query=mysql_query("SELECT * FROM events ORDER BY id ASC"); while($row = mysql_fetch_array($query)){ echo(" <tr> <td>".$row['id']."</td> <td>".$row['date']."</td> <td><a href=editdb.php?id=".$row['id']."&action=edit>".$row['name']."</a></td> </tr> "); } exit(0); ?> </table> <?php } ?> <form action="editdb.php" method="post"> <p>Date:</p> <input type="text" name="date" value="<? echo $row['date'] ?>" /> <p>Event Name:</p> <input type="text" name="name" value="<? echo $row['name'] ?>" /> <input type="submit" name="Submit1" value="Edit Existing" /> <p>Information:</p> <textarea name="text" rows="6" cols="50"><? echo $row['text'] ?></textarea> <input type="hidden" name="action" value="doedit" /> <input type="hidden" name="id" value="<? echo $row['id'] ?>" /> </form> <form action="editdb.php" method="post"> <input type="submit" name="Submit2" value="Delete Event" /> <input type="hidden" name="action" value="delete" /> <input type="hidden" name="id" value="<? echo $row['id'] ?>" /> </form> <? footer() ?> I'm very happy to have gotten this far.. but I need my footer. I also tried putting the edit delete script and html within a if statemant but coudn't get it to work either. Thanks again.
  4. Thanks for the quick reply! Your information was very helpful. I have read up in MySQL databases and created one that i have also successfully connected to in my site using PHP. My continued question is: What is the best way to manage my 'events' in the database? ... Is it complicated to create an small CMS (to manage my 'events' = delete, add, edit)? So that I have a table with checkmark inputs and different options. Or are there pre-made systems that I can use (that aren't as advanced as Wordpress/joomla/etc since i only want to manage this small section)? I realize these are many and vague questions. I am grateful for any input. This is my current test: http://naturalhorse.me/sites/testing/editdb.php And the code I am currently working around: <?php //Connect to Database include("connect.php"); //Retreive Data from events table $query="SELECT * FROM events"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <html> <body> <h2>Edit Events</h2> <p>Add, Edit and Delete your events here.</p> <table border="0"> <tr> <th>[ ]</th> <th>Order</th> <th>Date</th> <th>Name</th> </tr> <form name="events table" method="post" action="edit.php" /> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"id"); $f2=mysql_result($result,$i,"date"); $f3=mysql_result($result,$i,"name"); $f4=mysql_result($result,$i,"text"); ?> <tr> <td><input type="checkbox" value="check" name="select<?php echo $f1; ?>" /></td> <td><?php echo $f1; ?></td> <td><?php echo $f2; ?></td> <td><?php echo $f3; ?></td> </tr> <?php // $i++; } ?> <input type="submit" name="edit" value="edit"/> <input type="submit" name="delete" value="delete" /> </form> </table> <input type="submit" name="add new" value="new"/> </body> </html> Thanks, Isa
  5. Been scanning websites for any kind of help on the projects I'm running at the moment. Gave up on the scanning. Need real help. Need to get a real grasp on PHP. W3schools just doesn't cut it for me! Looking forward to actually understanding PHP versus desperately copy pasting other peoples scripts and crossing my fingers... SO if there are any php:ers out there who feel like lending a guiding hand, I am a warm receiver. I learn best by doing: here is my big project at the moment: http://www.phpfreaks.com/forums/php-coding-help/php-forms-editing-txt-within-site-events-'puzzle'/ Very greatfull for any support / advice! Thanks, Isa.
  6. I am very new to PHP and very eager to just understand all of the stuff i have been desperately trying to get to work for the last week. I decided to give up on copy pasting and actually find help. My main project right now is this: I want to have a website that I can edit from within a logged in section of the site (I've got the login part figured out - that is I have some code that at least has a pass and usrnm). I have a events page with 4 events, each event consisting of date, header and text: <div id="event"> <p class="date"> <? include_once('date.txt')?> </p> <h3> <? include_once('header.txt')?> </h3> <p class="eventinfo"> <? include_once('text.txt')?> </p> </div> I use .txt includes so that I can edit the actual texts inside of a form. My first attempt was to edit each file inside of one page. Failed due to <?php echo $_SERVER["PHP_SELF"] ?> . Second attempt was to have the page get edit.php file: <?php $fn1 = 'date.txt'; if (isset($_POST['content'])) { $content = stripslashes($_POST['content']); $fp1 = fopen($fn1,"w") or die ("Error opening file in write mode!"); fputs($fp1,$content); fclose($fp1) echo("Date has been saved") or die ("Error closing file!"); } ?> <form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post"> <textarea rows="5" cols="40" name="content"><?php readfile($fn1); ?></textarea> <input type="submit" value="Save"/> </form> And have the page reload and get edit header section, then reload again for the text. But didn't see how to do this without making three pages. What I want is that I can within at least tow pages do all the following: Login, choose which event to edit, then adit all three parts and save. My brains are fried from the combination of learning PHP and being over excited about having a working system. Hopefull for some answers! Thanks!! PS: my events page http://naturalhorse.me/sites/testing/events.php Thanks, Isa.
×
×
  • 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.