homepage Welcome to WebmasterWorld Guest from 23.22.29.137
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Submit content via form and have it appear in a specific spot
submit news, appears in specific spot
brettxw




msg:4267776
 5:11 am on Feb 16, 2011 (gmt 0)

Back with another question! :) I would like to be able to (only me) post submit content via form, and when I hit the post or submit button that content will appear in a specific spot on my page.

For example,

I go to the page (that I only know) and type in "WebmasterWorld.com is the best" and when I hit post or submit, that now appears at the top of my page in a fixed bar...This way I don't have to go in and edit the header.html to change the content every time.



Also, I've made a "thank you" shout out for all the help from you guys on my site! :)

 

JAB Creations




msg:4269617
 11:18 pm on Feb 19, 2011 (gmt 0)

Your question is very broad which implies way too much subjectivity for anyone to give you an answer that would help.

When you submit a form you have to capture the form at the server so where the form is aimed at and if there is something to capture it (e.g. <form action="file.php"> <input name="form_name_1" /> and then having if (isset($_POST['form_name_1'])) {do_stuff_function();}.

What you need to do is determine a pattern of form names that differentiate how PHP will handle the form data.

In example...

<?php
if ($_SERVER['REQUEST_METHOD']=='GET')
{
// GET requests
}
else if ($_SERVER['REQUEST_METHOD']=='POST')
{
if (isset($_POST['contact'])) {contact();}
else if (isset($_POST['news'])) {news();}
else if (isset($_POST['blog'])) {blog();}
else if (isset($_POST['forum_thread_publish'])) {forum_thread_publish();}
else if (isset($_POST['forum_thread_preview{forum_thread_preview();}
else if (isset($_POST['forum_post_publish'])) {forum_post_publish();}
else if (isset($_POST['forum_post_preview'])) {forum_post_preview();}
}
?>


Also do not rely on hidden URLs. If you don't have authentication with a database setup then you should stop whatever it is that you're doing and work on that first.

- John

brettxw




msg:4269627
 12:06 am on Feb 20, 2011 (gmt 0)

Thanks John for the reply. I can give an example of what I am looking to do...Example would be that I have word press at blog.example.com and I have a fixed bar on example.com at the top..I would like to some how (if can be) to show the last word press entry to appear in that network bar...

JAB Creations




msg:4269918
 9:50 pm on Feb 20, 2011 (gmt 0)

Whoa...okay so the first thing that crossed my mind: don't use WordPress. I used WordPress while I was learning how to work with MySQL and unless you're happy with the default stuff that you get from themes and such then you're going to end up putting way too much time in to it (and that doesn't include if you throw nightmares like jQuery in to the mix).

However if you're trying to figure out how to get it to work now use what I did like four years ago...

function user_date_mysql($date, $format) {return date ($format, strtotime($date));}

$result1 = mysql_query("SELECT post_date, post_name, post_title FROM wp_posts WHERE post_name != '' ORDER BY id DESC LIMIT 0,10");

if ($result1)
{
$row_count1 = mysql_num_rows($result1);

while($row1 = mysql_fetch_assoc($result1))
{
echo ' <div><a href="http://www.example.com/blog/'.$row1['post_name'].'" tabindex="3" title="'.htmlspecialchars($row1['post_title']).'">'.
/**** merge the line above and below, broke to keep forums from generating horizontal scrollbar ****/
user_date_mysql($row1['post_date'], "M d").', '.htmlspecialchars($row1['post_title']).'</a></div>'."\n";
}
}


This worked in probably older version of WordPress. Keep in mind their code is horrible spaghetti mesh so once I learned how to work with MySQL I cranked out my own blog in the span of three weeks (and my own forums, chat room, CMS, private messaging...etc) so f you're looking for something that won't break over time I'd highly recommend building stuff that will last. :)

- John

brettxw




msg:4269926
 10:18 pm on Feb 20, 2011 (gmt 0)

Ya, I don't love word press but I only use it for a blog for the site and not going crazy with it. If I knew how to code I would have coded something better then WP...Sadly, I don't and I live on this site haha.

rocknbil




msg:4270160
 5:48 pm on Feb 21, 2011 (gmt 0)

Brett, the thing about WordPress is you don't have to re-invent the wheel to use it. You should be able to modify your theme only and do something like this.

The first place I'd look is here, at query_posts() [codex.wordpress.org].

Create a copy of header.php and play around with that, you should be able to query the last post and get a snippet of any size you want with only a few lines of code inserted at the right place. Then whenever you update your blog, there it is.

If your content is outside what the authors call "The Loop", use get_posts() instead [codex.wordpress.org].

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved