- This topic is empty.
-
AuthorPosts
-
May 1, 2012 at 10:45 am #37871
chanman
MemberCan somebody please help me? I can’t figure how to make a html form post to a .txt file i know it takes a php script I just don’t know that much about php. All I need is first name, last name, and date. thanks.
May 2, 2012 at 9:43 am #102144chanman
MemberI don’t know, i’ve never used json before. let me tell you what i’m doing. One of my customers sites has baby registries on it they want their employees to be able to change them without having to edit the html code manually. So I wanted to create a html input form that will post the name and date somewhere so another script would read the names and post them on a page. I already have the one that reads a .txt file but I may have to change it now.
May 2, 2012 at 10:33 am #102148chanman
MemberI’m sorry but I pretty new to development and I don’t know how to do that either.
May 2, 2012 at 11:56 am #102152chanman
MemberI’m willing but I’m in high school so I might not be able to do everything right away. Also I’m with media temple so I’m pretty sure I can make a database pretty easy if your willing to help me everything.
May 2, 2012 at 3:08 pm #102162Staggers
MemberThis is a script I put together a while back. It puts stuff into the format ->
Title, Comment, Author, Date
extract($_POST,EXTR_SKIP);
//list($name,$com,$author,$date)
function CleanStr($str){
$str = trim($str); //Remove leading and trailing whitespace
if (get_magic_quotes_gpc()) { //magic quotes is deleted (?)
$str = stripslashes($str);
}
$str = htmlspecialchars($str);//remove html special chars
$str = str_replace("&", "&", $str);//remove ampersands
return str_replace(",", ",", $str);//remove commas and change to special chars # THIS IS VITAL!
}
if($_SERVER["REQUEST_METHOD"] != "POST") error("Error: No POST.",$dest);
// Check the contents of the form
if(!$name||ereg("^[ |@|]*$",$name)) $name=""; // If field is empty or that unknown Jap character found...
if(!$com||ereg("^[ |@|t]*$",$com)) $com=""; // and or a tab character...
if(!$sub||ereg("^[ |@|]*$",$author)) $author=""; // make field empty.
if(!$com) die("Please write something.");
$name = CleanStr($name);
$com = CleanStr($com);
$author = CleanStr($author);
$com = str_replace( "rn", "n", $com);
$com = str_replace( "r", "n", $com);
// Continuous lines
$com = ereg_replace("n((!@| )*n){3,}","n",$com);
$com = nl2br($com); //br is substituted before newline char
$com = str_replace("n", "", $com); //delete n from a string.
if($pass == "thisisthepassword") { // See that the password is correct
$filename = 'logfile.txt';
//set what will be written
$content_r = $name.",".$com.",".$author.",".date('l jS of F Y h:i:s A')."n"; //this will write in the values on a new line separated by commas
//write
$file = fopen($filename,"a") or die ("Error opening file in write mode!");
fputs($file,$content_r);
fclose($file) or die ("Error closing file!");
} //closing of If statement for the password.And this is the html form to go with it:
(excuse the table, but it makes it all neat and tidy)I hope this helps and makes a bit more sense, it works differently to the above scripts but variety in learning and techniques is always good.
May 3, 2012 at 9:49 am #102240chanman
MemberI said I was willing but I don’t think I could figure this out between school and work. Is there another way I could go about this just as a temporary. This is the test page you will have to create a login if you want to see what I have already done. Please don’t give up on me I’ve bee trying to figure this out forever.
If you dont want a create a login it’s
username:cordial
password: royalgmc
and then go to “A sample ‘members-only’ page”May 3, 2012 at 8:26 pm #102271chanman
MemberI had an idea, what about if I used a wordpress blog for posting the registries since I don’t have the time for the other stuff. It would be like each post was a registry and you could post and delete them whenever you wanted. Plus it would be easier on my customers employees. What do you think? Good or bad idea
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.