Jump to content

misterivanovich

Members
  • Posts

    21
  • Joined

  • Last visited

misterivanovich's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. *Bump*Looking for suggestions from my second post. I have all the HTML put into the database, now I just need some help recalling it. I'm honestly trying my best and getting nothing. =[
  2. Okay, so I have another question now. I have this stored under TABLE page where COLUMN p = deramo and COLUMN text = all that HTML.How do I recall it and display it? So far, I have my page set up to read a GET variable and set a $mysqlpage variable accordingly so I can use that in my MySQL query. If the GET variable isn't set or is set to index, $mysqlpage is set to deramo.Right now, I have the following.<?php$con = mysql_connect("mysql","******","******") or die('Could not connect: ' . mysql_error());mysql_select_db("******", $con);$result = mysql_query("SELECT * FROM person WHERE p = '$mysqlpage'");mysql_close($con);while($row = mysql_fetch_array($result)){ echo $row['text'];}echo $mysqlpage;?> This all, of course, is in the DIV where I want my content to be displayed. However, nothing prints out! I only echoed the $mysqlpage variable at the end to test and make sure it was setting it to deramo, and it is. Any ideas?
  3. I just ran this query through PhpMyAdmin and it yelled at me and gave me an error... Both are below. INSERT INTO page (p, text)VALUES ('deramo', '<html><head><style type="text/css">@import "http://letsfight.ulmb.com/school/css/font.css";body{ background-color: FFFFFF;}</style></head><body><b>Career-Based Intervention Program (CBIP)</b><br><br>The Career-Based Intervention Program is work-based learning/academic intervention program for students with barriers to career and academic success, and students who are not reaching their academic potential. The program promotes a learning environment in which there exists a sense of community with a common purpose, regonition of a learner's uniqueness, responsibilities and obligations, and assurance that the learner is engaged in a comprehensive program of acadmics, career and citizenship development, and work-based learning opportunities. In a school system where college is the rule rather than the exception, it is important that students who are having difficulty adjusting to the academic pressures or are falling prey to outside distractions are not lost in the academic scramble. CBIP at UAHS is designed to give students what they need to succeed, helping them academically and emotionally. Enrolling in CBIP is a step in the right direction for students who have past academic struggles. All CBIP students take regularly scheduled English, science, math, and history classes, as is dictated by their individual needs. English can be taken through CBIP (1 credit), in addition to the CBIP Related class (1 credit), which focuses on career planning, goal setting, human relation skills, test preparation, and finance, to name a few. Students also work outside of school, generally during the end of the school day in a private sector job.<br><br>Through the CBIP experience, students are given numerous opportunities to succeed, in a setting that profices bounaries and expectations, and improves time management skills and self-dicipline.</body></html>') MySQL said:#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's uniqueness, responsibilities and obligations, and assurance that the learner i' at line 2ERROR: Unknown Punctuation String @ 1732STR: >< I really have no idea what that means. Do I have to put a \ between everytime >< occurs?---EDIT---I missed the 's in the middle of the text. I'm just retarded. Fixed.
  4. Good deal!And then same goes for editing the content in a text area, correct? I can recall the information for the textarea tag and just have what is stored in the table be the original textarea content, then when I export it, I can just update the table, right? =]I think I'm beginning to understand all this MySQL junk and PHP stuff. It's so much easier when you actually have a teacher. ¬_¬
  5. The text that's stored in there can include HTML, correct? So I could just echo whatever I pull out of the database and it would parse it just as it has been by pulling it out and echoing everything? Just making sure. =PAlso, by eliminating the use of external websites to hold the information, how would I use my links? Would I have everthing just do GET variable links and work with it that way? Say, for instance...If I wanted to visit a page on woodshop, I could do index.php?p=wood as the link, and whatever the query is that pulls information out and displays it would be something like mysql_query(display_table($_GET['p'])), yeah? I mean, I know there's more crap that would be under both of those, but that's pretty much the basic, right?
  6. So that would be a yes?Should I consider it a large piece of text, or do I not even have to specify that? Can I just insert some text in there and call it a day?
  7. What I meant by setting the content equal to a variable is something like... This, I guess.$variable = "This would be the string of content on any given page.";**Pretend I inserted a textarea named newvariable with a POST method form. The original text in this textarea is $variable.**$variable = $_POST['newvariable']; You know? That way, you could easily take all the text on a page and change it. I suppose by using the file_get_contents function I could just take everything from the <body> tag to the </body> tag and then edit it that way - however, I wouldn't know how to put the NEW text or information back into the .php file. Is there a file_update_content function or something?
  8. You have all helped immensely in building my user login code for my admin area... And now I have to attempt to build said admin area!Now, I'm sure all I have to do is find a way to extract all of the content from a given .php file and make it into a variable, then stuff it back into the .php file when I'm done editing it... But I have no idea how to do this! Should I be storing my content on my MySQL databases so I can recall it in both the admin area for editing and the regular sites for viewing?Also, I would like to incorporate some buttons to make editing a little easier for the people here that don't know the first thing about HTML. I want to have them click a button and have a pop up dialogue box tell them to enter the URL then the text for any links they want, then tell them to enter URLs for pictures they want to put up, and have a button to click to create italicized, bolded or underlined text. Basically, just really simple stuff that I don't know how to make buttons for.Don't suppose I could get some help on this bit here too?
  9. Well... I went to the settings for the database I'm trying to connect to and it said the server name was "mysql." So I plugged that in, but to no avail. Would that be because I need to do "http://mysql.ulmb.com/" or something? =[i'm sorry that I fail at this. >_<---EDIT---Hah. Nevermind. I got it. =]
  10. Alright... Well, that doesn't really solve my problem of it still not logging in. =P But thank you, at least you cleared that bit up.Is it possible that I'm just being completely retarded and not logging into the database correctly? I mean, the localhost part threw me off... Because I don't have my database on my computer - it's hosted through UnlimitedMB. Should I be changing that part? I feel like it's something simple that I'm missing, not a large bit of code. =[---EDIT---Hah. Guess you edited before I replied!Thanks. =] I'll test it out, then edit with whether or not that solved everything.---EDIT #2---Hrmph. I'm still getting nothing. I'll post everything I have for my login page and my confirmation page. It's still acting pretty pissy.The following is for my LOGIN.PHP page.<?php session_start();echo '<html><head><title>Administrator\'s Login Area</title><style type="text/css">@import "http://letsfight.ulmb.com/school/css/font.css";#Center{ width: 100%; height: 100%; overflow: hidden;}</style></head><body><div id="Center" align="center"><table height="100%><tr><td style="height:25%;"></td></tr><tr><td align="center"><table><tr><td align="left"><h2> Login Area</h2></td></tr><tr><td align="center"><table><tr><td align="left">Username:</td></tr><tr><td align="center"><form action="http://letsfight.ulmb.com/school/logredir.php" method="post"><input type="text" style="width:80%;" name="name" value="" /></td></tr><tr><td align="left">Password:</td></tr><tr><td align="center"><input type="password" style="width:80%;" name="pass" value="" /></td></tr><tr><td align="right"><input type="submit" value="Submit" /></form></td></tr>';if ($_GET['r'] == 'y'){ echo '<tr><td align="right"><span class="red">Your username // password was incorrect.</span></td></tr>';}echo '</table></td></tr><tr><td style="height:30px;"></td></tr><tr><td align="center"><small>© Copyright Nicholas John Login Techniques. =P</small></td></tr></table></td></tr><tr><td></td></tr></table></div></body></html>';?> And this is for my LOGREDIR.PHP page. <?php$con = mysql_connect("localhost","******","******");mysql_select_db("******", $con);$name = mysql_real_escape_string($_POST['name']);$pass = mysql_real_escape_string($_POST['pass']);$pass = SHA1($pass);$search = mysql_query("SELECT * FROM users WHERE `name` = '".$name."' AND `pass` = '".$pass."'");$num_row = mysql_num_rows($search);if ($num_row > 0){ $_SESSION['logged'] = 1;}else{ $_SESSION['logged'] = 0;}mysql_close($con);if ($_SESSION['logged'] == 0){ $_SESSION['retrylog'] = 1; header ("Location: http://letsfight.ulmb.com/school/login.php?r=y");}else{ $_SESSION['retrylog'] = 0;}echo($_SESSION['logged']);?> The echo at the end is just to check on whether or not it's all working. But... I guess now I could just change it to actually have HTML after all of this just to say "You're logged in" or something.
  11. Thanks a ton! I'll try that out asap.Just curious, is it necessary to have the apostrophes around 'name' and 'pass'? And why did you put ".$name." instead of "$name"? Again... I'm learning as new ideas, concepts, and functions come into light, so bare with me if I ask dumb questions. =PMaybe I'll just get a book on all of this.---EDIT---Erm... Okay, so I put all that in, but it still always gives me a 0. Is it maybe because when I inserted the passwords into the table containing the usernames and passwords I used SHA('password')? Or would that have no affect on whether or not this worked?Also, I noticed that this forum ((and most others)) uses the GET variables to display all of the correct forums, and all the information and such... How can I get this effect? There isn't an iframe or a header code on the index, is there? I'm sure there's just another super simple aspect of PHP that you can laugh at me for not knowing yet. =P
  12. misterivanovich

    User Login

    Hey everyone... I've been having some trouble with my user login script I've been trying to write. I didn't really use a prewritten script or anything, just kinda took what other people in other forums have helped me with and pieced it all together.I'm teaching myself PHP one step at a time ((baby steps, big time)) to attempt to create a website for my school's Technology Education department. I want to create an Admin Area for all the teachers to log into and edit the content on their pages easily, sort of like a blog, but... I can't seem to get this user login code to work too well! I have the usernames and passwords stored on my MySQL database, but I don't know how to compare the names and passwords they enter on my login page to those I have stored on the server. What I've been doing so far ((which I'm sure is a disgrace to PHP scripting as a whole)) looks a little something like this... $con = mysql_connect("localhost","******","******"); mysql_select_db("******", $con); $name = $_POST['name']; $pass = $_POST['pass']; $search = mysql_query("SELECT * FROM users"); $row = mysql_fetch_array($search); if ($row['name'] == $name && $row['pass'] == $pass) { $_SESSION['logged'] = 1; } else { $_SESSION['logged'] = 0; } I'm sure you can pick up the obvious and probably understand what I was TRYING to do... But it's really not working out too well for me. It either ALWAYS sets my logged variable to 0 or ALWAYS sets it to 1. I'm getting really frusterated with how to compare these values! And I can't seem to find much, if any, information on it.I would appreciate any and all help. If you feel like you have an idea on how to fix it but need to see the full code that I have, just PM me and I'll reply with all of it.
×
×
  • Create New...