hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Help with simple form to page script...
Reply

Forum Jump

Help with simple form to page script...

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-14-2002, 04:10 AM
Chaps Chaps is offline
Junior Guru
 
Join Date: May 2002
Posts: 195

Help with simple form to page script...


Hi,

I need a little help here with something that I know should be fairly easy.

I have a guy writing an article for my site...instead of me downloading, formatting, coding, copying and pasting every week to update the article...I want to create a form that will have different text areas (about 10) which he can fill in the differetn sections of his article in all the text areas, hits submit, and the entered info is written to a php file...that's easy enough except...how do I get it to stay there? Like I want it so once he submits his article and it writes to the file...everyone can see it and it will stay there UNTIL he writes a new article...and hits submit, then the new info will overwrite the last article.

Anyone have an easy way to do this???



Sponsored Links
  #2  
Old 09-14-2002, 04:32 AM
prosayist prosayist is offline
Junior Guru Wannabe
 
Join Date: Dec 2001
Location: New Hampshire
Posts: 93
<form action="<?=$PHP_SELF?>"><textarea name="stufftosubmit" rows="7" cols="77"></textarea><input type="submit" name="submit"></form><a href="page.html">page.html</a>

<?
if($submit){$updatedpage=fopen('page.html','w');
fputs($updatedpage, stripslashes($stufftosubmit));
fclose($updatedpage);
}?>

[EDIT]wrong attributes; this is a textarea, not an image [/EDIT]
[EDITAGAIN]added stripslashes(), otherwise y'get those nasty \s all over the place with quotes [/EDITAGAIN]

__________________
WYSIWYG


Last edited by prosayist; 09-14-2002 at 04:54 AM.
  #3  
Old 09-14-2002, 04:55 AM
Chaps Chaps is offline
Junior Guru
 
Join Date: May 2002
Posts: 195
could you be more specific as to what to do with that?

thanx

__________________
Lime Drop Marketing!
Web Design | Graphic Design | Logo Design
http://www.limedrop.ca

Sponsored Links
  #4  
Old 09-14-2002, 05:01 AM
prosayist prosayist is offline
Junior Guru Wannabe
 
Join Date: Dec 2001
Location: New Hampshire
Posts: 93
yeah;
-make a page called (for example) "formpage.php"
-put all that code in it
-repeat "about 10" times
-load it to your server/browser
-type something in the textarea
-submit
-click the link to 'page.html'
it's very simple and prob'ly you'll wanna make it better but I think it'll get you goin'
anything else?

__________________
WYSIWYG

  #5  
Old 09-14-2002, 05:02 AM
Chaps Chaps is offline
Junior Guru
 
Join Date: May 2002
Posts: 195
okay so...

I put that code into the text area's page...there will be multiple textareas does that change anything?

Then it writes to page.html or page.txt, whatever...

Then to I want to have a <?php require ("page.txt"); ?> in the page that I want the article to appear? Is that how this will work in full?

  #6  
Old 09-14-2002, 05:12 AM
Chaps Chaps is offline
Junior Guru
 
Join Date: May 2002
Posts: 195
Thanx but..

okay that works...but one question...the stuff he submits...I want html tags around the stuff he submits...and also some text he won't be submitting like headings.

For example:

OFFENSE:
Quarterbacks: The Riders have great depth, yada yada yada.
EDGE: Riders

K so in that example...he will be submitting the "The Riders have great..." paragraph. I want it to that it also writes the offense and quarterbacks lines...and the Edge line (he will submit 'Riders' in a text box)...and I also want to have it so when he submits it...his submission will have <p> tags (paragraph tags in case it accepted the html and u can't read the tag) around it.

How do I accomplish this?

  #7  
Old 09-14-2002, 05:14 AM
Chaps Chaps is offline
Junior Guru
 
Join Date: May 2002
Posts: 195
Oh and this might be too much work...but is there any way to archive the current article before its written over? Possibly have it so that when he enters a new article, it will rename the current one, and then use the original name for the updated one?

__________________
Lime Drop Marketing!
Web Design | Graphic Design | Logo Design
http://www.limedrop.ca

  #8  
Old 09-14-2002, 05:15 AM
prosayist prosayist is offline
Junior Guru Wannabe
 
Join Date: Dec 2001
Location: New Hampshire
Posts: 93
YEAH, of COURSE there's a way! (with PHP, there's always a way)
I'm not gonna write the whole script for ya 'cause, as you said, it's simple..
All ya' gotta do is add <input type="text" name="OFFENSE" (or whatever your variable name is) and make a new variable so
PHP Code:
$formattedOFFENSE=<h3>$OFFENSE</h3>;
/*same for your other things you want formatted, then, using the same syntax as before*/
fopen('page.txt','w');
print 
'$formattedOFFENSE' 
it's a quite a bit more complicated than what I've explained but quite a bit easier than what you'd expect..
just do a little research, check out the manual at php.net, look on PHP Builder, do a google search; somebody's prob'ly already got something written for what you're tryinna do

__________________
WYSIWYG


Last edited by prosayist; 09-14-2002 at 05:28 AM.
  #9  
Old 09-14-2002, 05:18 AM
Chaps Chaps is offline
Junior Guru
 
Join Date: May 2002
Posts: 195
actually don't worry about the file renaming archive thing...I can do that a different way...no worries.

__________________
Lime Drop Marketing!
Web Design | Graphic Design | Logo Design
http://www.limedrop.ca

  #10  
Old 09-14-2002, 05:38 AM
prosayist prosayist is offline
Junior Guru Wannabe
 
Join Date: Dec 2001
Location: New Hampshire
Posts: 93
like this (for example).. add other <input name="?"> for your other variables;
PHP Code:
<form action="<?=$PHPSELF?>">
<h3>HEADER:
<br>
<input type="text" name="header"></h3>
<p>CONTENT:
<br>
<textarea name="stufftosubmit" rows="7" cols="77">
</textarea>
<input type="submit" name="submit">
</p>
</form>
<a href="page.html">page.html</a>

<?
if($submit){
$updatedpage=fopen('page.html','w');
$header='<h3>'.$header.'</h3>';
$content=stripslashes($stufftosubmit);
fputs($updatedpage,($header.'<br><p>'.$content.'</p>'));
fclose($updatedpage); 
}
?>

__________________
WYSIWYG

  #11  
Old 09-14-2002, 05:53 AM
Chaps Chaps is offline
Junior Guru
 
Join Date: May 2002
Posts: 195
Okay thats cool...

sorry to keep bugging ya...

But I tried putting styles sheets on the page I have that calls the page.txt and now nothing comes up at all...?

__________________
Lime Drop Marketing!
Web Design | Graphic Design | Logo Design
http://www.limedrop.ca

  #12  
Old 09-14-2002, 05:54 AM
Chaps Chaps is offline
Junior Guru
 
Join Date: May 2002
Posts: 195
but hey don't worry about that...cuz I'm an idiot and firgure it out as soon as I posted that...

hehe...

Thanx a ton for your help anyways!!!

__________________
Lime Drop Marketing!
Web Design | Graphic Design | Logo Design
http://www.limedrop.ca

  #13  
Old 09-14-2002, 06:01 AM
prosayist prosayist is offline
Junior Guru Wannabe
 
Join Date: Dec 2001
Location: New Hampshire
Posts: 93
hey, Welx a ton back at ya

__________________
WYSIWYG

  #14  
Old 09-14-2002, 07:25 AM
Chaps Chaps is offline
Junior Guru
 
Join Date: May 2002
Posts: 195
hope you see this...

actually that worked...but...

I must have too much information to submit because when i fill out all my form fields with about as much info as would be entered normally...it won't work...it justs clicks and nothing happens. If I only put a couple things in...it works perfect.

This is no doubt due to the query string right?

I mean when you submit...there is a huge query string of EVERYTHING that was submitted right in the address bar...likely with the amount of info I am putting in...it's too much?

Anyways...do you know how to fix this?

Currently the script is sitting at http://www.riderfans.com/myphp/myphp.php

__________________
Lime Drop Marketing!
Web Design | Graphic Design | Logo Design
http://www.limedrop.ca

  #15  
Old 09-14-2002, 01:42 PM
prosayist prosayist is offline
Junior Guru Wannabe
 
Join Date: Dec 2001
Location: New Hampshire
Posts: 93
try adding this;
"<form method="post">"
(if you're not using the 'action' attribute, you don't even need to put it there)

__________________
WYSIWYG

Reply

Related posts from TheWhir.com
Title Type Date Posted
AHosting Launches ClipBucket-Optimized Web Hosting Web Hosting News 2014-07-21 10:29:12
Web Hosting Sales and Promos Roundup - December 6, 2013 Web Hosting News 2014-05-23 15:42:37
Hurricane Electric Expands Globally with Two New Canadian PoPs Web Hosting News 2013-08-08 14:50:16
Nasuni Launches Cloud Mirroring Feature to Storage Solution Web Hosting News 2013-08-08 14:15:27
OpenStack and the AWS API Debate Web Hosting News 2014-05-09 12:40:29


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:
WHT Membership
WHT Membership



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?