Advertisement

07.13.2008 at 09:19PM PDT, ID: 23561677 | Points: 500
[x]
Attachment Details

How Do I Create Files and Pass Variables from an Input Form and Write it to the New Files?

Asked by FirstBorn in PHP Scripting Language

Tags: php

Hi,

Thanks for helping.

Attached are My scripts for an input form and
a script to create different files using the info
from the input form.

Basically, there is an input form.
On this input form, there are a few variables that
get passed from this form to create a few other
pages (simple, no design necessary)...

I have MOST of the code that will be needed
for the content... just need the code to create the
other files and to pass the variables from the input
form to these new files created by submitting the
input form's "Submit" button.

There needs to be an error check/handler, too,
but just to make sure that all of the fields on the
submit form has been entered before hitting the
submit button.

Also, need for to make sure that the current code has the
correct syntax in certain areas, such as, using
[$filename] with a prefix, such as 'gateway$filename.php'
(not sure of the correct syntax for that.)

Can anyone help Me?

Thanks,
FirstBorn
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
// Input Form Fields
<p align='Center'>
<form action="createpages.php">
PayPal email:<br>
<input type="Text" name="email"><br><br>
File name:<br>
<input type="Text" name="filename"><br><br>
Name of product:<br>
<input type="Text" name="sys_item_name"><br><br>
Personal Identifier (Product ID) of product:<br>
<input type="Text" name="sys_item_number"><br><br>
Price of product:<br>
<input type="Text" name="sys_item_cost"><br><br>
Thank You page URL:<br>
<input type="Text" name="sys_item_download_url"><br><br>
PayPal Cancel URL:<br>
<input type="Text" name="sys_item_cancel_url"><br><br>
Exact Ebook Download location<br>
<input type="Text" name="DLURL"><br><br>
<input type="reset" name="Clear">&nbsp; &nbsp;
<input type="submit" name="Submit">&nbsp; &nbsp;
</form>
</p>
 
// =======================================
//======================================================
// createpages.php below:
 
<?php
 
// Get data from previous input form,
// then create and write the file...
 
$order_contents="
// PayPal Email Address<br>
$email=$_GET["email"];<br>
// THIS is what the NEW file name will be (.php)<br>
$filename=$_GET["filename"];<br>
// Product Name<br>
$sys_item_name=$_GET["sys_item_name"];
// Product Number specified on the previous form<br>
$sys_item_number=$_GET["sys_item_number"];<br>
// Cost of Item<br>
$sys_item_cost=$_GET["sys_item_cost"];<br>
// Login page to product<br>
$sys_item_download_url=$_GET["sys_item_download_url"];<br>
// Where user will go if they press cancel instead of ordering<br>
$sys_item_cancel_url=$_GET["sys_item_cancel_url"];<br><br>
// This is the EXACT URL for the .pdf file.<br>
 
// All of the stuff below must be sent to the "order[filename].php" file:
// basically, the file should show the $var="actual var" with
// the above examples...
// and what is written below:
$email = urlencode($email);<br>
$sys_item_name = urlencode($sys_item_name);<br>
$sys_item_number = urlencode($sys_item_number);<br>
$sys_item_cost = urlencode($sys_item_cost);<br>
//$sys_item_download_url = urlencode($sys_item_download_url . "?orderid=" . time());<br>
$sys_item_download_url = urlencode($sys_item_download_url);<br>
$sys_item_cancel_url = urlencode($sys_item_cancel_url);<br><br>
 
header("Location: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=$email&item_name=$sys_item_name&item_number=$sys_item_number&amount=$sys_item_cost&no_shipping=2&return=$sys_item_download_url&cancel_return=$sys_item_cancel_url&no_note=1&currency_code=USD&lc=US&bn=PP%2dBuyNowBF&charset=UTF%2d8");<br>
exit;<br>
"
// now, create order$filename.php and write $order_contents to the file.
 
// End of "order[filename].php content,
// create and write file code goes here!
 
//======================================================
// now, let's move on to login[filename].php
$login_contents="<?
session_start();
 
if($_POST["submit"]) {
 
// Load up from POST
$email=$_POST['email'];
$_SESSION['email'] = $email;
 
//echo "Session is set as - $_SESSION[\'email\']";
 
// Validate Email Address
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
 
	if (isset($_SESSION['email'])) {
	//  echo "Valid email address.";
	header ("Location: http://test.com/gateway + . + $filename");
	  exit;
 
	} else {
	// echo "Invalid email address.";
		die("you must log in.");
		}
	}
} ELSE {	
?>
<HTML>
<head>
<meta name="robots" content="noindex,nofollow">
<title>Login to ebook</title>
</head>
<BODY>
<p>Please Enter Your email Address to access Your Ebook<br>
(it MUST Be a VALID Email Address)</p>
<form action="<?php print $_SERVER["PHP_SELF"]; ?>" method="post">
<input type="text" name="email" size="15" maxlength="150">
<input type="hidden" name="submit" value="Submit">
<input type="submit" name="submit" value="Submit">
<input type="reset"></div>
</form>
</body>
</html>
<? } ?> "
 
// now, create login$filename.php and write $login_contents to the file.
 
//======================================================
// next, let's move on to gateway[filename].php
 
$gateway_contents="<?
//php sessions code goes here!
session_start();
 
$ip = $_SERVER['REMOTE_ADDR'];
$fullhost = gethostbyaddr($ip);
$host = preg_replace("/^[^.]+./", "*.", $fullhost);
 
// Build message parts
$recipient = "$email";
$headers .= "From: Gateway$filename <$email>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
 
 
if (isset($_SESSION['email'])) {
$email = $_SESSION['email'];
$subject = "Gateway$filename has been Accessed.";
$message = "Gateway$filename has been Accessed by IP address: $ip -  | Host: $host.<br>with the following email address: $email"; 
$message = stripslashes($message);
 
// Send mail
mail($recipient,$subject,$message,$headers); 
 
?>
<HTML>
<meta name="robots" content="noindex,nofollow">
<BODY>
<p>Would You like to Download the file or read it online?
<p>Please Choose by clicking the appropriate link below.
 
<p>Click This Link to Download Your Ebook:<br>
<a href="$filenamedl.php">$sys_item_name</a>
 
<p>&nbsp;
<p>Please forward any Technical Difficulties to <a href="mailto:$email">Here by Clicking This Link</a>
<p>Enjoy!
</BODY>
</HTML>
<?
 
} ELSE {
 
	$ip = $_SERVER['REMOTE_ADDR'];
	$cname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
	$fullhost = gethostbyaddr($ip);
	$host = preg_replace("/^[^.]+./", "*.", $fullhost);
    	echo "You are not authorized to view this page.<br>";
        echo "Your IP Address <font color='red'><b> $ip </b></font>has been Logged.<br>";
        echo "Your Host is: <font color='red'><b> $host </b></font>.<br>";
 
$subject = "Gateway$filename Access Attempt.";
$message = "Someone has attempted to access Gateway$filename by IP address: $ip -  | Host: $host.<br>without entering a Valid Email Address."; 
$message = stripslashes($message);
 
// Send mail
mail($recipient,$subject,$message,$headers); 
 
}
 
?>"
 
// k, now, create gateway$filename.php and write $gateway_contents to the file.
 
//======================================================
// k, finally, let's move on to [filename]dl.php
$DLURL=$_GET["DLURL"];
 
$dlcontents="
<?
 
//php sessions code goes here!
session_start();
 
if (isset($_SESSION['email'])) {
 
	$path="./$DLURL";
 
	header("Content-Type: application/force-download");
	header("Content-Transfer-Encoding: binary");
	header('Content-Length: '.filesize($path));
	header("Content-Disposition: attachment; filename=\"" . basename($path) . "\"");
	header('Pragma: no-cache');
	readfile($path);
 
} ELSE {
 
	$ip = $_SERVER['REMOTE_ADDR'];
	$cname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
	$fullhost = gethostbyaddr($ip);
	$host = preg_replace("/^[^.]+./", "*.", $fullhost);
    	echo "You are not authorized to view this page.<br>";
        echo "Your IP Address <font color='red'><b> $ip </b></font>has been Logged.<br>";
        echo "Your Host is: <font color='red'><b> $host </b></font>.<br>";
}
 
?>
"
// k, now, create $filenamedl.php and write $dlcontents to the file.
 
// end of procedures
//======================================================
 
?>
[+][-]07.13.2008 at 09:30PM PDT, ID: 21995645

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.13.2008 at 09:47PM PDT, ID: 21995701

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 04:59AM PDT, ID: 21997234

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 05:14AM PDT, ID: 21997324

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 05:46AM PDT, ID: 21997528

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 10:39PM PDT, ID: 22004359

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.15.2008 at 06:23PM PDT, ID: 22012593

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.15.2008 at 06:28PM PDT, ID: 22012607

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.15.2008 at 08:38PM PDT, ID: 22013139

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.15.2008 at 08:45PM PDT, ID: 22013164

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 04:56AM PDT, ID: 22014949

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 04:28PM PDT, ID: 22021100

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 06:03PM PDT, ID: 22021562

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 10:22PM PDT, ID: 22022518

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 05:34AM PDT, ID: 22024675

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 07:17PM PDT, ID: 22032421

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 08:17PM PDT, ID: 22032639

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 08:31PM PDT, ID: 22032694

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 08:47PM PDT, ID: 22032745

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 08:59PM PDT, ID: 22032784

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 09:04PM PDT, ID: 22032800

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 09:06PM PDT, ID: 22032812

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 09:36PM PDT, ID: 22032914

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 09:38PM PDT, ID: 22032923

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.18.2008 at 05:41AM PDT, ID: 22035069

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.18.2008 at 03:23PM PDT, ID: 22040325

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.18.2008 at 03:24PM PDT, ID: 22040326

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.18.2008 at 05:59PM PDT, ID: 22040985

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.18.2008 at 11:12PM PDT, ID: 22041525

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.19.2008 at 07:43AM PDT, ID: 22042609

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.19.2008 at 07:17PM PDT, ID: 22044244

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.21.2008 at 06:38PM PDT, ID: 22055963

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 04:06PM PDT, ID: 22064504

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 04:14PM PDT, ID: 22064552

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 04:21PM PDT, ID: 22064588

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 04:33PM PDT, ID: 22064658

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 05:31PM PDT, ID: 22065029

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 05:34PM PDT, ID: 22065045

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 05:42PM PDT, ID: 22065099

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 05:46PM PDT, ID: 22065120

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 05:54PM PDT, ID: 22065152

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 06:06PM PDT, ID: 22065214

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 06:06PM PDT, ID: 22065217

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 06:10PM PDT, ID: 22065237

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 11:16PM PDT, ID: 22066456

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 07:05AM PDT, ID: 22069412

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 05:49PM PDT, ID: 22075331

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628