Jump to content

[SOLVED] PHP $_Post $Get Function Help Needed Please


lewisstevens1

Recommended Posts

Hi i think i have to use the php function $_post and $_get functionis... but i am not sure... i have a image showing what i want to do, can someone help me, its verry basic but looking around on all forums i cant find.

 

it needs to be stored on a server for a bit untill then next submition of the data.

 

i want it so they can post a daily update of the progress of the development.

 

sever.jpg

 

heres a link to the image: http://i261.photobucket.com/albums/ii64/lewisstevens1/sever.jpg

Link to comment
Share on other sites

Perhaps not as basic as you think since it involves data storage not just processing post or get.

 

If you want some control over passwords and users and want to save a progression of progress comments then MySQL is the best route and won't be too difficult to implement once you learn the basics.

 

If you really only want to display a page and that can be overwritten, and you're prepared to hard code a password then you can forget MySQL and treat it as a very simple content management system.  The admin page would require a password matching something saved in your php file, the page would then convert the entered data to a file e.g. xml, the user page would then just call this page up.

 

2nd method is simpler but 1st may be more useful and rewarding in the long run...

Link to comment
Share on other sites

lol well the page will only be one password which i can easily do on my server... nothing to code.

 

but i just want something which overwrites the last post... it should just be

like a display window.. where you see whats posted in there, though when you

log off it will stay there untill someone changes it.

Link to comment
Share on other sites

Well its not something I have done much myself so don't know the most secure way etc. but the following is the basic idea:

 

admin.html

<form method="post" action="processAdmin.php">
  <textarea rows="5" cols="20" name="progress"></textarea>
  <input type="submit" />
</form>

 

processAdmin.php

$progress=CLEANED VERSION of $_POST['progress'];

$f=fopen("progress.txt","w");

fputs($f,$progress);  //$progress is the text you want to display from the admin form
fclose($f);

 

and the user page:

 

user.php

$f=fopen("progress.txt","r");
while (!eof($f)){
  $line=fgets($f);
  echo $line,"<br/>";
}
fclose($f);

 

Not tested I'm afraid so if that works first time you're a lucky person.  As I say I may have overlooked some security issues since I've never used this in anger only when I was first learning PHP.  I'm sure others will let you know if I have!!

Link to comment
Share on other sites

=S well the code does not work, though unlike HTML and CSS...

i dont av a clue what half of it does.

i understand

 

while

get

echo

$

$_post

 

and all this

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

  <textarea rows="5" cols="20" name="progress"></textarea>

  <input type="submit" />

</form>

 

just not sure about the rest

Link to comment
Share on other sites

The error i get from admin.html is:

$progress=CLEANED VERSION of $_POST['progress']; $f=fopen("progress.txt","w"); fputs($f,$progress); //$progress is the text you want to display from the admin form fclose($f);

 

So it just displays the code of the page after i have pressed submit, after entering some data.

 

then it just stays there, so i edit the url  to /user.php then it just comes up with:

$f=fopen("progress.txt","r"); while (!eof($f)){ $line=fgets($f); echo $line,"

"; } fclose($f);

Link to comment
Share on other sites

OK - I didn't post the exact script, just a suggestion on what to do...  This should at least work:

 

processAdmin.php

<?php
$progress=$_POST['progress'];//forget about cleaning up for now...  but it must be done somewhen

$f=fopen("progress.txt","w");

fputs($f,$progress);  //$progress is the text you want to display from the admin form
fclose($f);

echo "Progress updated";
?>

<!-- You can now add some html to link to wherever you want.. -->

 

 

user.php

<?php
$f=fopen("progress.txt","r");
while (!eof($f)){
  $line=fgets($f);
  echo $line,"<br/>";
}
fclose($f);
?>

 

No disrespect, we all have to start somewhen, but if you did not spot that I missed the <?php ?> tags then perhaps you need to do a bit of learning first.

 

I have posted a basic framework - you should adapt to suit your needs with html doctypes/tags etc.

Link to comment
Share on other sites

My advice would be to learn a bit more PHP so you can understand the code.

 

=S well the code does not work, though unlike HTML and CSS...

i dont av a clue what half of it does.

i understand

 

while

get

echo

$

$_post

 

and all this

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

  <textarea rows="5" cols="20" name="progress"></textarea>

  <input type="submit" />

</form>

 

just not sure about the rest

Link to comment
Share on other sites

Fatal error: Call to undefined function eof() in /home/stonersg/public_html/Lee/user.php on line 3

 

i have:

 

<?php

$f=fopen("progress.txt","r");

while (!eof($f)){

  $line=fgets($f);

  echo $line,"<br/>";

}

fclose($f);

?>

 

so line 3 is: while (!eof($f)){

which calls f?

mmm im just wondering about the progress.txt

 

ive created a file on my server called progress.txt and saved as a blank

.txt doc... is that whats needed?

Link to comment
Share on other sites

You mean to display as a text box in the user.php file?  If so:

 

<form>  <!-- not sure what you want to do with it if anything... -->
  <textarea rows="5" cols="20" disabled="disabled"><?php
$f=fopen("progress.txt","r");
while (!eof($f)){
  $line=fgets($f);
  echo $line,"<br/>";
}
fclose($f);
?></textarea>
</form>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.