Jump to content

In need of "Mini-CMS" code for simple form processing.


sakonnetweb

Recommended Posts

Hello

 

I code by hand (HTML & CF -14 years now), and some of my customers want the ability to do updates to their sites themselves using Adobe Contribute, and I can build any app they need that Contribute can't handle in CF if they host on my server - however, in this particular case, the site is hosted by GoDaddy which is no longer supporting CF.

 

The site is PHP-enabled, and the client was using WordPress to update his entire site. Because of the blogging-centric features of Wordpress, a user can enter a "headline" then an associated story (commentary) - publish, and the headline ends up on one page linked to the page where the headline and story live.

 

So, I need a simple form handler written in PHP  that allows the client to enter his "headline" (which is a hard-coded link to the "rest of the story" page), the headline showing up above the story content (using a second form field) - not necessarily targeting <a href="#end-up-here"> - just simply land on the page where the content gets dynamically displayed.

 

Thanks in advance for your patience and be kind---- I have never written a line of PHP- just thousands of lines  of CF.....

 

 

 

Norman

Link to comment
Share on other sites

WTF is the question then if you're going to come back and say oh this tool is better even though you clearly can't use it?

BTW, Cold Fusion? I almost fell out of my chair laughing, thanks.

Link to comment
Share on other sites

I don't understand exactly what you're trying to do.

 

You've explained you want to make a form, and you've explained you want it handled. Did you want this information to interact with Wordpress directly? If so, you may want to ask for help in our 3rd Party forum, or the Wordpress site itself.

 

Google's got load of PHP form classes.

https://www.google.com/?q=php+form+class

Link to comment
Share on other sites

Do not want to use WordPress- just a simple form with 2 fields- "Headline" and "Story" - after submitting, the headline will display on the headline page:

 

<a href="storypage.html">Headline- see more:</a>

 

Then the story simply displays on the storypage.html with the headline above it- I suppose the submitted data would need to be stored in in a DB- that's how I would handle it with CF.

 

Thanks for your help.

 

 

 

 

Link to comment
Share on other sites

You'll have to be more specific if you want a more specific solution.

 

Are you have problems building a form?

Are you having problems collecting the data from that form?

Are you having problems inserting the data into the database?

Which database server are you using?

Why storypage.html and not storypage.php?

Link to comment
Share on other sites

create a form

<form method="post" action="submitform.php">

<input type="text" name="headline">
<textarea name="story" rows="2" cols="20"></textarea>

<input type="submit" value="Publish">
</form>

---submitform.php

<?php
//connect to server
$con = mysql_connect("server","user","pw");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
//select database
mysql_select_db("Your_Database", $con);
//take what they wrote in the form into a var
$headline = $_POST['headline'];
$story = $_POST['story'];

//put it inside the table or show an error
mysql_query("INSERT INTO Your_Table (Headline, Story)
VALUES ('$headline', '$story')")or die(mysql_error());
//display something for user if it worked
echo 'Successfully put ' . $headline . ' into the database.';

mysql_close($con);
?>

 

You will need a mysql database with a table that contains 3 rows a unique ID as primary key and auto increment, and two fields for Headline and Story

 

To display all headlines and make them clickable through to their unique page to show its content.

 

--index.php

<?php
//connect to server
$con = mysql_connect("server","user","pw");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
//select database
mysql_select_db("Your_Database", $con);
//take what they wrote in the form into a var

$result = mysql_query("SELECT * FROM Your_Table");

echo "<table>
<tr>
<th>Headline</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>";
  echo '<a href="display.php?uniqueID=';
  echo $row['uniqueID'] . '">';
  echo $row['Headline'];
  echo '</a>';
  echo "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?> 

 

To display

 

---display.php

<?php
//connect to server
$con = mysql_connect("server","user","pw");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
//select database
mysql_select_db("Your_Database", $con);
//take what they wrote in the form into a var
$uniqueID = $_GET['uniqueID'];
$result = mysql_query("SELECT * FROM Your_Table where uniqueID = '$uniqueID'");

echo "<table>
<tr>
<th>Headline</th>
<th>Story</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['Headline'] . "</td>";
  echo "<td>" . $row['Story'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?> 

 

something like this? not tested..

Link to comment
Share on other sites

Thanks for everyone's help.

 

Re: Learning PHP. I will be 62 this year- this is the first time I was backed into a corner, i.e. could not convince a client to let me host their site ( I host about 75 now) but needed a dynamic CMS app.

 

IOW I will be retired in a couple of years- I know, old dog-new tricks is not for Web Developers, but I'm so close.....

Link to comment
Share on other sites

It sounds like the service you offer isn't the service they want. It's always ok to fire a client. It's usually less stressful than trying to make it work.

If they paid you enough, you'd be better off outsourcing the project. But just keep in mind when it breaks, you have to fix it or find someone who can and pay them.

Link to comment
Share on other sites

Hmm- WTF? ColdFusion is a laughing matter? Not hardly-

 

1) PHP is most likely to be found in use on Adult (14.75%) , Business (14.75%) or Technology (11%) type websites.

 

2) Adobe ColdFusion is most likely to be found in use on Business (21%), Shopping (20%) or Travel (13%) type websites.

 

I don't host "Adult" Websites- and I'm certainly not a "ColdFusion God" ....

 

But, thanks for your opinion.

Link to comment
Share on other sites

jesirose:

 

Not familiar with that term- I'm old enough to be your grandfather- probably why.

 

I didn't post to this forum to discuss (or argue) the merits of PHP vs. CF- just for some advice.

 

BTW just because a dynamic Web development platform costs money doesn't mean it's bad.

 

But again, thanks for your feedback.

 

 

Link to comment
Share on other sites

 

I didn't post to this forum to discuss (or argue) the merits of PHP vs. CF- just for some advice.

 

BTW just because a dynamic Web development platform costs money doesn't mean it's bad.

 

But again, thanks for your feedback.

 

 

That's weird, because that's what you're doing...

You have no idea why I laughed when I saw you're using cold fusion. It couldn't possibly be because I've used it in the past, that wouldn't be a possibility at all I guess I'm way too young for that gramps.

 

You did get plenty of advise. You rejected it and got more advice. You rejected THAT and got more advice. Why don't you tell us what you want to hear and someone can c&p it for you.

 

I didn't belittle you for being old, don't assume that because I and most of the people here are younger than you that we don't have a clue what we're talking about.

 

Btw: if you care about statistics regarding language use, this one is MUCH more interesting to me:

http://w3techs.com/technologies/overview/programming_language/all

 

Everyone knows that when Al Gore invented the Internet, he had "adult" websites in mind. Google "avenue Q the Internet is for porn" if you want a laugh.

 

 

Link to comment
Share on other sites

Why did this discussion go in this direction? I'm going to ask a mod to close this thread.

 

@sakonnetweb - If you still need help, please open a new thread, and be more descriptive of what you need help with. We understand what you want to accomplish, but we aren't here to teach you from the ground up, were here to help with speed bumps. Though it seems downah has provided you with a fairly complete response, I haven't had time to look it over and verify best practises and secure database interaction (it seems like it's missing).

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.