PDA

View Full Version : Form to edit php file



Jabbic
10-09-2005, 03:18 PM
How can i make a form that you submit then it edits a bit of a php file?
THanks :eusa_danc

zak-x
10-09-2005, 03:20 PM
Form Code Details:

The QuikCode Wizard helps you to create HTML form code similar to the following:

<FORM METHOD="POST" ACTION="http://www.yoursite.com/cgi-bin/quikstore.cgi">

<INPUT TYPE="text" NAME="item-ZZ101|14.95|Candy|NA|1" size="3">

<INPUT TYPE="hidden" NAME="store_type" VALUE="html">

<INPUT TYPE="hidden" NAME="page" VALUE="products1.html">

<INPUT TYPE="submit" NAME="add_to_cart" VALUE="Add to Cart">

</FORM>

The first line is the opens the <form> and sets the method and action for the form. The "Method" should be POST and the "Action" should be set to the URL where the "quikstore.cgi" program is located on your server.


The second line in this example identifies the product and all of its' parameters. These parameters include product id, unit price, product name, size, and weight variables separated by pipes (|). This line is also the Quantity Box where the user selects a specified quantity to purchase.


Line number three tells the Quikstore program what type of store (store_type) is adding the item to the cart. This is so we can properly direct the user back to where they came from. The "store_type" variable is only required in HTML based stores.


Line number four tells the Quikstore program what the name of the page is that you are adding to the cart from. This page name is then used by the program to return the customer to the page they came from after they have added an item to their cart.

This page value MUST be the name of the current page. If you have this page in a subdirectory of the document root, you need to add the subdirectory name in front of the page name like this: VALUE="subdirectory/pagename.html" otherwise you will get a security check error when you try to add something to the cart.

DO NOT add a forward slash to the beginning of the page value like this: VALUE="/subdirectory/pagename.html". That will not work properly.


Line five is simply the Add To Cart button.

Line six closes the form tag.

At minimum, each <form> must contain the values listed above.

If you want more than one item on a page, and you would like to be able to add multiple items at one time, you would repeat ONLY the item specific lines above like this:

<FORM METHOD="POST" ACTION="http://www.yoursite.com/cgi-bin/quikstore.cgi">

<INPUT TYPE="hidden" NAME="store_type" VALUE="html">
<INPUT TYPE="hidden" NAME="page" VALUE="products1.html">

<P>Candy:

<INPUT TYPE="text" NAME="item-ZZ101|14.95|Candy|NA|1" size="3">
<INPUT TYPE="submit" NAME="add_to_cart" VALUE="Add to Cart"></p>

<P>Toy:

<INPUT TYPE="text" NAME="item-ZZ102|14.95|Toy|NA|1" size="3">
<INPUT TYPE="submit" NAME="add_to_cart" VALUE="Add to Cart"></p>

</FORM>

Each item must be identified individually. You may use more than one Add to Cart button or simply have one at the bottom of the form. Just continue to add additional lines as shown above, for each new item. There is no need to repeat the hidden "page" and "store_type" tags.

The example below is a complete basic HTML page and will place four input boxes on one page with an "Add to Cart" button at the bottom. Each item has different information and should be accompanied by the necessary pictures, graphics and text to assist the customer in making a choice. Based on the choice selected and the quantity input by the customer, the required parameters will be passed to the "quikstore.cgi" program by the "form" which is executed when the customer presses the "Add to Cart" button.

<HTML>
<HEAD>
<TITLE>Enter your title here.</TITLE>
</HEAD>
<BODY>

<FORM METHOD="POST" ACTION="http://www.yoursite.com/cgi-bin/quikstore.cgi">
<INPUT TYPE="hidden" NAME="page" VALUE="products.html">
<INPUT TYPE="hidden" NAME="store_type" VALUE="html">

<P>Candy
<INPUT TYPE="text" NAME="item-ZZ101|14.95|Candy|NA|1" SIZE="3"></P>

<P>More Candy
<INPUT TYPE="text" NAME="item-ZZ102|18.95|More Candy|NA|1" SIZE="3"></P>

<P>Alot of Candy
<INPUT TYPE="text" NAME="item-ZZ103|24.95|Alot Of Candy|NA|1" SIZE="3"></P>

<P><INPUT TYPE="submit" NAME="add_to_cart" VALUE="Add to Cart">

</FORM>
</BODY>
</HTML>

there you go =]

Jabbic
10-09-2005, 03:22 PM
What??????

Jabbic
10-09-2005, 03:23 PM
That doesn't edit a selected bit of a php file does it?
Edit by Michael-W (Forum Mod): Please don't double post, use the 'edit' feature instead.

zak-x
10-09-2005, 03:24 PM
Sorry i sent you wrong thing lmaoo

Jabbic
10-09-2005, 03:25 PM
can you send the right one lol :P

Jabbic
10-09-2005, 03:33 PM
if you have it

мϊкэ
10-09-2005, 04:01 PM
right make a file called edit.php and add this code


<?
// Submission Part
if ($submit) {
$fp = fopen('YOURPAGE.php', 'w');
fwrite($fp, stripslashes($newdata));
fclose($fp);
}

$fp = fopen('YOURPAGE.php', 'r');
while (!feof($fp)) {
$data .= fgets($fp, 4096);
}
fclose($fp);
echo "
<html>
<head>
<title>PAGE</title>
</head>

<body>
<form action='edit.php' method='post'>
<textarea name='newdata' rows='20' cols='50'>
$data
</textarea>
<br>
<input type='submit' name='submit' value='Submit'>
</form>
</body>
</html>";
?>

That should workk... ive taken it from my cms, so im not sure if the code is completely right...

Jabbic
11-09-2005, 07:40 AM
How does it work?

Jabbic
11-09-2005, 08:26 AM
can anyone help me?

splintercell!
11-09-2005, 08:28 AM
it would help if you gave us the type of script your trying to make.

Jabbic
11-09-2005, 09:01 AM
how can i give you it if i want it made. Or do you mean like php? If so its php

splintercell!
11-09-2005, 09:14 AM
no what type of thing are you trying to make??

Jabbic
11-09-2005, 09:17 AM
You need to read the start of the thread

Jabbic
12-09-2005, 08:38 PM
THe script that guy posted was good but it edits the whole file. I only want to edit a bit of the file

Want to hide these adverts? Register an account for free!