Jump to content

yoshida

Members
  • Posts

    293
  • Joined

  • Last visited

Everything posted by yoshida

  1. yoshida

    undefined index

    True. I guess I should convert the $_GET['pageid'] method to classes then?
  2. yoshida

    required fields?

    Ah thanks... it's very wise to keep an extra set of eyes on quotes and such.Luckily, my editor has code highlighting (all quoted text turns pink) so I guess I'm a bit lazy that way.
  3. Search for a tutorial on how to setup an AMP (Apache, Mysql, PHP) or install easyphp, and go to the php/mysql tutorial on freewebmasterhelp.com. I never heard of such thing as compiling php but I do use Crimson Editor (which uses code highlighting).
  4. yoshida

    required fields?

    //handler;$field1=$_POST['field1'];$field2=$_POST['field2'];$field3=$_POST['field3']; if ($field1 == "" || $field2 == "" || $field3 == "") {//checks if a user actually filled all required fieldsecho "you didn't fill all required fields;} else {query or other action here;} In short, this code checks if any posted value is blank ("") and executes the appropriate script. The required fields should be separated as shown.
  5. yoshida

    What's secure?

    I know I did a topic on login scripts already, but don't want to compare to 'my way' anymore so everyone can speak freely of what's 'most secure'.In short: I've made a index.php with content manager, and (obviously) don't want 'just anyone' to use it. So I made a login script which relies on the mysql database and a session, to unlock certain features.What's one thing you ALWAYS would like to see in ANY login script, to be certain you're safe? I'd really like to put my best effort into this because the content manager is very easy to use (which is also a downside for security reasons).So... some code or linkage please thnx
  6. EDIT: FIXED!$query="SELECT * FROM news ORDER BY date DESC LIMIT 1";How do I query a database to only echo the latest entry from a certain table? I know how to display data and order it by a certain field, but I only want to display the latest adition (the one with the newest date).Date is formatted as yyyymmdd so that's what it's sorted by.Thanks
  7. yoshida

    undefined index

    The newest Easyphp sure knows how to do that... instead of the oldfashioned 'let's just ignore that $pageid isn't defined yet' it now thinks 'let's inform the writer of this script that he is stupid'. There's nothing wrong with a parser not ignoring 'fishy scripts'. But then there should be a way to fix that, so that a milion people who adopted a certain method of working don't have to re-design their scripts.
  8. yoshida

    undefined index

    I use Crimson Editor, it uses code highlighting as showed in my crap-ified avvi. The parser itself is some kind of validator, but I don't know if version 4 is different from 5 in that way.
  9. yoshida

    undefined index

    Solved...ish let's say it's not a problem anymore.Any way to validate php?
  10. yoshida

    undefined index

    Guess what: my host seems to have 'dumbened down' their php. No errors there.
  11. Thanks. I'll try that.EDIT: works like a charm! Thanks again
  12. yoshida

    undefined index

    My pc is just a test site, the final result will be uploaded to our domain. So I have no control over which php will be used. Besides, I'm trying to solve the problem not avoid it.What's HTTP_GET_VARS[var]? Sounds like something I want to learn.
  13. Dutch That's the line that reads the info from the database, $gcon is echoed into a table a few lines later.$gcon=$_POST['gcon']; (in the handler - read comment) pulls it out, and into the query. I believe I should put $gcon=str_replace("n","<br>",$gcon); there?I'll play around with it for a while Had to use str_replace for smileys anyway, still learning how to get that right.Thanks.
  14. yoshida

    undefined index

    WinXP. Thought php was cross platform?Anyway, I use a texteditor to write php (have created a 450 line index.php with multiple scripts, which are triggered by page id).EDIT: would it help if I use the switch function?
  15. I'm stupid, where should I implement this? if ($pageid == 'gastenboek') { $command=$_GET['command']; if ($command == 'write') { //write section; if (isset($_POST['akkoord'])) { //handler; $gnam=$_POST['gnam']; $gmal=$_POST['gmal']; $datum=$_POST['datum']; $gdat=$_POST['gdat']; $page=$_POST['page']; $gcon=$_POST['gcon']; if ($gnam == "" || $gcon == "") { //checks if a user actually left his name and message after the beep; echo "<div id=warning>Niet alle verplichte velden zijn ingevuld. <meta http-equiv=refresh content=\"3; url=index.php?pageid=gastenboek&command=write\">"; } else { $query="INSERT INTO gastenboek VALUES ('','$gnam','$gmal','$page','$datum','$gdat','$gcon')"; mysql_query($query); echo "<div id=warning>Uw bericht is toegevoegd, dank u wel.<meta http-equiv=refresh content=\"3; url=index.php?pageid=gastenboek\"></div>"; } } else { //form; echo "<form action=index.php?pageid=gastenboek&command=write method=post>"; $date=date('ymdHi'); $maand_array = array("januari", "februari", "maart", "april","mei", "juni", "juli", "augustus", "september","oktober", "november", "december"); $datum = date("j ") . $maand_array[date("n") - 1] . date(" Y"); echo "<table><tr><td><b>Naam:</b><td><input type=text name=gnam size=40></tr>"; echo "<tr><td><b>E-mailadres:</b><td><input type=text name=gmal size=40></tr>"; echo "<tr><td><b>Website:</b> http://<td><input type=text name=page size=40></tr></table><br>"; echo "<b>Datum:</b>$datum<input type=hidden name=gdat value='$date'><input type=hidden name=datum value='$datum'>"; echo "<br><textarea rows=20 cols=88 name=gcon></textarea><br><input type=submit name=akkoord value='voeg toe'>"; } } else { //loads the guestbook from the database, and sorts everything the same way as the newspage does; //This database however, stores everything as yymmddhhmm to sort everything by minute; //The date dd month yyyy is stored separately; $query="SELECT * from GASTENBOEK ORDER BY 'gdat' DESC"; $result=mysql_query($query); $num=mysql_num_rows($result); echo "<div id=schaduw><div id=header>Gastenboek</div></div>"; echo "<div id=schaduw><div id=werklaag>"; echo "<a href=index.php?pageid=gastenboek&command=write>Voeg een bericht toe</a>"; echo "<p><table cellspacing=0 cellpadding=0>"; $i=0; //The userdetail table and the message table are loaded next to each other, in the main table; //The table echo is been split by row, to enhance read- and editability. Never hurts to have more rows... ; while($i < $num) { $name=mysql_result($result,$i,"gnam"); $mail=mysql_result($result,$i,"gmal"); $datum=mysql_result($result,$i,"datum"); $gcon=mysql_result($result,$i,"gcon"); $page=mysql_result($result,$i,"page"); echo "<tr><td valign=top>"; //userinfo table; echo "<table cellpadding=0 cellspacing=0 border=1 width=300>"; echo "<tr><td height=30 width=110><td></tr>"; echo "<tr><td bgcolor=#606060><td bgcolor=#606060></tr>"; echo "<tr><td><b>Naam</b><td>$name</tr>"; echo "<tr><td><b>E-mail</b><td><a href=mailto:$mail>$mail</a></tr>"; echo "<tr><td><b>Homepage</b><td><a href=http://$page target=0>$page</a></tr>"; echo "<tr><td><b>Geplaatst op</b><td>$datum</tr></table>"; //spacer; echo "<td width=1 bgcolor=#606060>"; //message table; echo "<td valign=top><table cellspacing=0 cellpadding=0 border=1>"; echo "<tr><td height=30></tr>"; echo "<tr><td bgcolor=#606060></tr>"; echo "<tr><td>$gcon</tr></table></tr>"; $i++; } echo "</table></p>"; echo "</div></div>"; }}
  16. yoshida

    undefined index

    I just upgraded my old lamp to easyphp (the lazy solution) and found out that $_GET['pageid'] triggers a warning: How do I get rid of this? Or am I just stupid? I know the pageid should be defined before reading it, but I don't know how to do that and still make it trigger scripts (if $pageid=blabla {run this script;})
  17. This may be very simple, but how do I auto-forward to an url? For example: you're auto forwarded after a forum notification. How do I do that?
  18. I've written this guest book, but it came to my attention that when you hit enter in the textarea, the line break isn't saved in the database. So everything you type is displayed as one line of text.How can I make sure the line break is displayed without users needing to type <br>?It's a regular text area, saved as a blob.This problem is semi-crucial to finishing my index.php
  19. yoshida

    login script

    Nope, sorry. I hate cookies.As I said earlier/somewhere else I just use a login script to hide a content manager. The best I can do is create a logfile (if that) to keep track of who changed what when. Beyond that I'm lost.Shouldn't be too hard to figure it out tho... as long as you keep in mind what it should do and what in/outputs are available.
  20. yoshida

    login script

    I guess letting the login script change the status from zero to one would be a good start... but that would require every user to log off before closing the browser window.(select * from users where login='1' order by 'logintime' asc) or somethin like that
  21. I use this: #r0 { display: block; overflow: hidden; height: 2px; background: #222299;}#r1 { display: block; overflow: hidden; height: 1px; background: #fafaff; margin: 0px 8px;}#r2 { display: block; overflow: hidden; height: 1px; background: #f9f9ff; margin: 0px 6px;}#r3 { display: block; overflow: hidden; height: 1px; background: #f8f8ff; margin: 0px 4px;}#r4 { display: block; overflow: hidden; height: 1px; background: #f7f7ff; margin: 0px 3px;}#r5 { display: block; overflow: hidden; height: 2px; background: #f6f6ff; margin: 0px 2px;}#r6 { display: block; overflow: hidden; height: 3px; background: #f5f5ff; margin: 0px 1px;}#inhoud { background: #f4f4ff; padding: 5px;} then this: <div id=r1></div><div id=r2></div><div id=r3></div><div id=r4></div><div id=r5></div><div id=r6></div> <div id=inhoud>blablabla </div> <div id=r6></div><div id=r5></div><div id=r4></div><div id=r3></div><div id=r2></div><div id=r1></div> and it looks like this.The code isn't 100% efficient (should've used classes for instance) but it does the J-O-B.
  22. Seems like I'm not that good with PHP as I thought I'm having one chunky 300 line index.php with close to 10 pageid scripts. Thought of calling it 'eggshell', since nested if's hatch solutions (geekhumor).
  23. I'm doing the same thing.The index.php first fetches the ?id=this from the address, by using $id=$_GET['id']; it now knowt $id=this.I figure the entire index.php is a bunch of nested IF statements. So basically IF ($id == 'this') { load the page named 'this' from the database }Example: my (incomplete) one-page guestbook! $pageid=$_GET['pageid'];if ($pageid == 'gastenboek') { if ($pageid == 'write') { if (isset($_POST['akkoord'])) { $gnam=$_POST['gnam']; $gmal=$_POST['gmal']; $gdat=$_POST['date']; $gcon=$_POST['gcon']; if ($gnam == "" || $gmal == "" || $gcon == "") { echo "Niet alle verplichte velden zijn ingevuld. <a href=index.php?pageid=write>opnieuw</a>"; } else { mysql_connect('localhost',$user,$pass); mysql_select_db($dbas) or die( "Unable to select database"); $query="INSERT INTO gastenboek VALUES ('','gnam','gmal','gdat','gcon'"; mysql_query($query); echo "Uw bericht is toegevoegd, dank u wel."; mysql_close(); } } else { echo "<form action=index.php?pageid=write method=post>"; $date=date('ymdHi'); $maand_array = array("januari", "februari", "maart", "april","mei", "juni", "juli", "augustus", "september","oktober", "november", "december"); $datum = date("j ") . $maand_array[date("n") - 1] . date(" Y"); echo "<table><tr><td><b>Naam</b><td><b>E-mailadres</b></tr><tr><td><input type=text name=gnam size=30><td> <input type=text name=gmal size=40></tr></tr><table><br><b>Datum:</b>$datum<input type=hidden name=gdat value=$date>"; echo "<br><textarea rows=20 cols=70 name=gcon></textarea><br><input type=submit name=akkoord value='voeg toe'>"; } } else { mysql_connect('localhost',$user,$pass); mysql_select_db($dbas) or die( "kan database niet vinden."); $query="SELECT * from GASTENBOEK ORDER BY date ASC"; $result=mysql_query($query); $num=mysql_num_rows($result); $i=1; while($i < $num) { $name=mysql_result($result,$i,"gnam"); $mail=mysql_result($result,$i,"gmal"); $date=mysql_result($result,$i,"gdat"); $gcon=mysql_result($result,$i,"naam"); $i++; echo ""; } }}if ($pageid='somethingelse') { \\run some script} So when I link to index.php?pageid='gastenboek' it'll execute the script assigned to the $pageid=gastenboek.Hope this makes things clear.Welcome to the forums dude
  24. yoshida

    smileys

    Agreed, I crawl when I'm drunk, walk when I'm stupid and bike when I'm in the mood. Smart people use a car (hmm... cheatsheets?) or public transport (forum-ish).Sorry for the jabbing, my eggshell made me wake up at 4 AM for three nights in a row, and kept me pondering untill 6:30 (when I had to wake up for work). Yeah... what am I doing to myself... :)Final results by the end of next week.[/hype-ing]
×
×
  • Create New...