Jump to content

johnseito

Members
  • Posts

    138
  • Joined

  • Last visited

Everything posted by johnseito

  1. Yup I checked yours, and I was wondering why in your code you don't have connection to the database. I was thinking how it would work without connection. I just changed the code from $HTTP_POST_VARS to $_POST[] and now the code looks like: <HTML> <HEAD> <TITLE>Add a Weblog Entry</TITLE> </HEAD> <BODY> <H1>Add an Entry</H1> <form method="POST" action="addentry.php"> <b>Title:</b><br> <input type="text" name="entrytitle"><br> <b>Weblog Entry:</b><br> <textarea cols="60" rows="6" name="entrytext"> </textarea><br> <input type="submit" name="submit" value="Submit"> </form> </BODY> <?php if (isset($_POST['submit'])) { mysql_connect("localhost","root","root"); mysql_select_db("weblog"); $entrytitle=$_POST['entrytitle']; $entrytext=$_POST['entrytext']; $query ="INSERT INTO weblog (entrytitle,entrytext)"; $query.=" VALUES ('$entrytitle','$entrytext')"; $result=mysql_query($query); if ($result) echo "<b>Successfully Posted!</b>"; else echo "<b>ERROR: unable to post.</b>"; } ?> </HTML> It didn't give any error, it gives nothing. I filled the form and click submit then I went to localhost/weblog.php and refresh it and nothing happens.
  2. [code][code][code]Ok I created a database called Weblog and table called weblog in mySQL such as: [code] CREATE TABLE weblog ( entrydate TIMESTAMP PRIMARY KEY, entrytitle VARCHAR(100), entrytext TEXT); then I created a php file called addentry.php the form where people can filled and hit submit to send it to the database [/code] <HTML> <HEAD> <TITLE>Add a Weblog Entry</TITLE> </HEAD> <BODY> <H1>Add an Entry</H1> <form method="POST" action="addentry.php"> <b>Title:</b><br> <input type="text" name="entrytitle"><br> <b>Weblog Entry:</b><br> <textarea cols="60" rows="6" name="entrytext"> </textarea><br> <input type="submit" name="submit" value="Submit"> </form> </BODY> <?php if ($HTTP_POST_VARS['submit']) { mysql_connect("localhost","root","root"); mysql_select_db("weblog"); $entrytitle=$HTTP_POST_VARS['entrytitle']; $entrytext=$HTTP_POST_VARS['entrytext']; $query ="INSERT INTO weblog (entrytitle,entrytext)"; $query.=" VALUES ('$entrytitle','$entrytext')"; $result=mysql_query($query); if ($result) echo "<b>Successfully Posted!</b>"; else echo "<b>ERROR: unable to post.</b>"; } ?> </HTML> [/code] then I create a weblog php files called weblog.php to show the result of when someone filled the form and click submit [/code] <html> <head><title>Untitled</title></head> <body> <h1>Weblog Example</h1> <dl> <?php mysql_connect("localhost","root","root"); mysql_select_db("weblog"); $query ="SELECT entrytitle, entrytext,"; $query.=" DATE_FORMAT(entrydate, '%M %d, %Y') AS date"; $query.=" FROM weblog ORDER BY entrydate DESC LIMIT 10"; $result=mysql_query($query); while (list($entrytitle,$entrytext,$entrydate) = mysql_fetch_row($result)) { echo "<dt><b>$entrytitle ($entrydate)</b></dt>"; echo "<dd>$entrytext</dd>"; } ?> </dl> </body> </html> [/code] The result didn't come out with what I am expecting, the result are Weblog Example and doesn't show any input. Could someone take a look and let me know what is wrong, thanks.
  3. Thanks, I'll check out these codes and let you know if I have any questions.
  4. I do have a book but could you show me a code example of how I can add the post to the database then display it, for example have someone post it then save it in database, but still have what they post on the page, one on top of another, etc. thanks
  5. I have a database but not sure how it work, and not sure how a flat file works either. Could you explain both? I guess in the end I will use a database, but do you mean a database such as mySQL? thanks --
  6. The same page where the forms are. For example when someone post, it will store the his/her post on top of the form, and then when the 2nd poster post, his/her post will be on top of the post before. this will all happen on the same page and the forms will still be there for the 3rd and 4th post, etc.
  7. Hello everyone, I was wondering if someone could help me with this. I already created the form for a text box, name field, subject etc. I would like this text box that when someone types something into and click the submit button, it will take what they wrote and place it on top of the form with the time and date, plus the name of the person and subject which was enter when this person filled this form. then if the 2nd person post it will place what he/she posted on top of the last post but the post before should always be there also. All this will be on the same page. Thanks Here is what i have <code> <?php txt(); function txt(){ print<<<HERE <h3 id="respond">Leave a Reply</h3> <form action="http://www.yaomingmania.com/blog/wp-comments-post.php" method="post" id="commentform"> <p><input type="text" name="author" value="" size="22"/> <label for="author"><small>Name (required)</small></label></p> <p><input type="text" name="email" value="" size="22"/> <label for="email"><small>Mail(required)</small></label></p> <p><input type="text" name="url" value="" size="22" /> <label for="url"><small>Subject</small></label></p> <p><textarea name="comment" cols="100%" rows="10"></textarea></p> <p><input name="submit" type="submit" value="Submit Comment" /> <input type="hidden" name="comment_post_ID" value="700" /> </p> </form> HERE; } ?> </code>
  8. works great thanks-
  9. for example: I use double for loop to do this for ($i = 0; $i < $height; $i++) { } for ($j = 0; $j < $width; $j++) { print "<font size =6.5>_</font>"; print("<font size=5>|</font>"); } the thing is that I can't get the number on the column and rows. thanks
  10. Hello, I was wondering if someone could show me the PHP code for building a GRID with numbers in each column and rows as axis. thanks -
  11. Hello, I would like to know a good PHP application out there that I can download and use. Right now I am writing my codes mostly in notepad. I also would like to know if the PHP application can run html codes such as PHP program that are associated to html program with forms. example: In note pad we have to save these two program in the same directory and then in the browser type localhost/xyz.html to run the form and then from the html form we enter values etc then hit submit to run the PHP program. please let me know where I can download a good PHP application to use to write PHP programs. thanks ~
×
×
  • 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.