Here's what I'm trying to do:
1) Make a Membership system with PHP, powered by MySQL
2) Make a simple Weblog that is tied into the Membership
system, so when you post news, they can click on your name,
and it goes to the dynamicly generated page w/ info entered
when the member registers into the DB.
Now, I alrdy have a *simple* Weblog script;
<!-- m --><a class="postlink" href="http://korn.lp-hc.us/add.php">http://korn.lp-hc.us/add.php</a><!-- m --> <-- Add news (try it)
<!-- m --><a class="postlink" href="http://korn.lp-hc.us/news.php">http://korn.lp-hc.us/news.php</a><!-- m --> <-- View the News (try it)
Now, I'd like to elimate the 'Author Name' and
'Author Email' fields, and those basicly automaticly
filled in, with the username / their email (from the MySQL DB)
here's the coding for both the pages:
add.php - the code
<html>
<head>
<title>Add News Entry</title>
</head>
<body>
<form method="post" action="process.php">
<b>Author Name</b>:
<br>
<input type="text" name="entryauthor">
<br><Br>
<b>Author Email</b>:
<br>
<input type="text" name="entryemail">
<br><Br>
<b>Entry Title</b>:
<br>
<input type="text" name="entrytitle">
<br><Br>
<b>Entry Message</b>:
<br>
<textarea cols="75" rows="10" name="entrytext"></textarea>
<br><Br>
<input type="submit" name="submit" value="Submit">
</form>
</body></html>
process.php - the code
<?php
if ($HTTP_POST_VARS['submit']) {
$dbh=mysql_connect ("localhost", "user", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("weblog");
$entryauthor = $HTTP_POST_VARS['entryauthor'];
$entryemail = $HTTP_POST_VARS['entryemail'];
$entrytitle = $HTTP_POST_VARS['entrytitle'];
$entrytext = $HTTP_POST_VARS['entrytext'];
$query ="INSERT INTO weblog (entryauthor,entryemail,entrytitle,entrytext)";
$query.=" VALUES ('$entryauthor', '$entryemail', '$entrytitle', '$entrytext')";
$result=mysql_query($query);
if ($result) echo "<b>Successfully Posted!</b>";
else echo "<b>ERROR: unable to post!</b>";
}
?>
news.php - the code
<?php
$dbh=mysql_connect ("localhost", "user, "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("weblog");
$query ="SELECT entryauthor, entryemail, entrytitle, entrytext, DATE_FORMAT(entrydate, '%M %d, %Y')";
$query.=" AS date FROM weblog ORDER BY entrydate DESC LIMIT 10";
$result=mysql_query($query);
while (list($entryauthor,$entryemail,$entrytitle,$entrytext,$entrydate) =
mysql_fetch_row($result)) {
echo "<table width=\"50%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" bordercolor=\"Red\">";
echo "<tr align=\"center\"><td align=\"center\">$entrytitle</td></tr>";
echo "<tr align=\"center\"><td align=\"center\"><br>$entrytext</td></tr>";
echo "<tr align=\"center\"><td align=\"center\">Posted by - <A href=http://www.htmlforums.com/archive/index.php/\"mailto:$entryemail?subject=News Posting\">$entryauthor</a> on $entrydate</td>";
echo "</table><br><Br><Br>";
}
?>
I built the majority of it off a simple tutorial here:
<!-- m --><a class="postlink" href="http://www.wsworkshop.com/php/php-mysql-weblog.html">http://www.wsworkshop.com/php/php-mysql-weblog.html</a><!-- m -->
As you'll see, I've added the Author Name/Email parts,
modified the outlook, etc.
Anywhose; like I said above, how would I create a *simple*
membership area to do the following:
1) allow members to access the add news page;
2) allow them to enter their name, email, website,
URL to their avatar, etc.
3) having it automaticly fill out the author part
on the news page, to go to a dynamicly-generated
page with their info, etc.; as well the option to
use the HTML <img> tag to show the avatar on news posts;
Thnkx in advance for any/all replies, etc. first you need to add a user table to your mysql.
then you need a page similar to what you have but for the info of the user...
then you have to build a login page which store the userid in a session or cookie, then when someone add a news, get the id from the session and store it with the news in mysql.here's the SQL (run via Command Line or phpMyAdmin) I got:
CREATE TABLE weblog (
entrydate TIMESTAMP PRIMARY KEY,
entryauthor VARCHAR(100),
entryemail VARCHAR(100),
entrytitle VARCHAR(100),
entrytext TEXT);
so I'd also want to make (and run) this SQL code:
CREATE TABLE users (
joindate TIMESTAMP PRIMARY KEY,
user VARCHAR(25),
pass VARCHAR(15),
email VARCHAR(100),
website VARCHAR(100),
avatar VARCHAR(100),
dscpt TEXT);
but how would I link the user colum in
the table users to the table weblog??
As well, how to validate the info in the pass colum
is the same for that user in that row?? etc.first, i don't think that joindate is a good primary key...
i always use int auto_increment
then you have to remove the columns
entryauthor
entryemail
and add
user
so when you add a weblog, you have to enter the primary key of the user into the weblog table (foreigh key if i don't mispell)
when you have a login system, you have something like session, and you can have variable in them, so you put the user id in a session variable and use this when adding a weblog instead of using post variable...
well i don't think i'm very good at description like that, i'm better with some code...
1) Make a Membership system with PHP, powered by MySQL
2) Make a simple Weblog that is tied into the Membership
system, so when you post news, they can click on your name,
and it goes to the dynamicly generated page w/ info entered
when the member registers into the DB.
Now, I alrdy have a *simple* Weblog script;
<!-- m --><a class="postlink" href="http://korn.lp-hc.us/add.php">http://korn.lp-hc.us/add.php</a><!-- m --> <-- Add news (try it)
<!-- m --><a class="postlink" href="http://korn.lp-hc.us/news.php">http://korn.lp-hc.us/news.php</a><!-- m --> <-- View the News (try it)
Now, I'd like to elimate the 'Author Name' and
'Author Email' fields, and those basicly automaticly
filled in, with the username / their email (from the MySQL DB)
here's the coding for both the pages:
add.php - the code
<html>
<head>
<title>Add News Entry</title>
</head>
<body>
<form method="post" action="process.php">
<b>Author Name</b>:
<br>
<input type="text" name="entryauthor">
<br><Br>
<b>Author Email</b>:
<br>
<input type="text" name="entryemail">
<br><Br>
<b>Entry Title</b>:
<br>
<input type="text" name="entrytitle">
<br><Br>
<b>Entry Message</b>:
<br>
<textarea cols="75" rows="10" name="entrytext"></textarea>
<br><Br>
<input type="submit" name="submit" value="Submit">
</form>
</body></html>
process.php - the code
<?php
if ($HTTP_POST_VARS['submit']) {
$dbh=mysql_connect ("localhost", "user", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("weblog");
$entryauthor = $HTTP_POST_VARS['entryauthor'];
$entryemail = $HTTP_POST_VARS['entryemail'];
$entrytitle = $HTTP_POST_VARS['entrytitle'];
$entrytext = $HTTP_POST_VARS['entrytext'];
$query ="INSERT INTO weblog (entryauthor,entryemail,entrytitle,entrytext)";
$query.=" VALUES ('$entryauthor', '$entryemail', '$entrytitle', '$entrytext')";
$result=mysql_query($query);
if ($result) echo "<b>Successfully Posted!</b>";
else echo "<b>ERROR: unable to post!</b>";
}
?>
news.php - the code
<?php
$dbh=mysql_connect ("localhost", "user, "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("weblog");
$query ="SELECT entryauthor, entryemail, entrytitle, entrytext, DATE_FORMAT(entrydate, '%M %d, %Y')";
$query.=" AS date FROM weblog ORDER BY entrydate DESC LIMIT 10";
$result=mysql_query($query);
while (list($entryauthor,$entryemail,$entrytitle,$entrytext,$entrydate) =
mysql_fetch_row($result)) {
echo "<table width=\"50%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" bordercolor=\"Red\">";
echo "<tr align=\"center\"><td align=\"center\">$entrytitle</td></tr>";
echo "<tr align=\"center\"><td align=\"center\"><br>$entrytext</td></tr>";
echo "<tr align=\"center\"><td align=\"center\">Posted by - <A href=http://www.htmlforums.com/archive/index.php/\"mailto:$entryemail?subject=News Posting\">$entryauthor</a> on $entrydate</td>";
echo "</table><br><Br><Br>";
}
?>
I built the majority of it off a simple tutorial here:
<!-- m --><a class="postlink" href="http://www.wsworkshop.com/php/php-mysql-weblog.html">http://www.wsworkshop.com/php/php-mysql-weblog.html</a><!-- m -->
As you'll see, I've added the Author Name/Email parts,
modified the outlook, etc.
Anywhose; like I said above, how would I create a *simple*
membership area to do the following:
1) allow members to access the add news page;
2) allow them to enter their name, email, website,
URL to their avatar, etc.
3) having it automaticly fill out the author part
on the news page, to go to a dynamicly-generated
page with their info, etc.; as well the option to
use the HTML <img> tag to show the avatar on news posts;
Thnkx in advance for any/all replies, etc. first you need to add a user table to your mysql.
then you need a page similar to what you have but for the info of the user...
then you have to build a login page which store the userid in a session or cookie, then when someone add a news, get the id from the session and store it with the news in mysql.here's the SQL (run via Command Line or phpMyAdmin) I got:
CREATE TABLE weblog (
entrydate TIMESTAMP PRIMARY KEY,
entryauthor VARCHAR(100),
entryemail VARCHAR(100),
entrytitle VARCHAR(100),
entrytext TEXT);
so I'd also want to make (and run) this SQL code:
CREATE TABLE users (
joindate TIMESTAMP PRIMARY KEY,
user VARCHAR(25),
pass VARCHAR(15),
email VARCHAR(100),
website VARCHAR(100),
avatar VARCHAR(100),
dscpt TEXT);
but how would I link the user colum in
the table users to the table weblog??
As well, how to validate the info in the pass colum
is the same for that user in that row?? etc.first, i don't think that joindate is a good primary key...
i always use int auto_increment
then you have to remove the columns
entryauthor
entryemail
and add
user
so when you add a weblog, you have to enter the primary key of the user into the weblog table (foreigh key if i don't mispell)
when you have a login system, you have something like session, and you can have variable in them, so you put the user id in a session variable and use this when adding a weblog instead of using post variable...
well i don't think i'm very good at description like that, i'm better with some code...