Webmaster Forum


Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #21 (permalink)  
Old 04-29-2007, 07:23 PM
daniel0012's Avatar
Member
 
Join Date: 11-07-06
Location: Springfield
Posts: 111
iTrader: 0 / 0%
They're in the same file, the form tag is closed and when I put in that code it returned

Quote:
array(0) { }
 
Reply With Quote
  #22 (permalink)  
Old 04-29-2007, 07:34 PM
brealmz's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 04-10-07
Posts: 75
iTrader: 0 / 0%
var_dump($HTTP_POST_VARS);

if it was not empty use that instead of post
__________________
 
Reply With Quote
  #23 (permalink)  
Old 04-29-2007, 09:13 PM
daniel0012's Avatar
Member
 
Join Date: 11-07-06
Location: Springfield
Posts: 111
iTrader: 0 / 0%
They are two seperate files in the same directory, the form tag is closed and the code returned
Quote:
array(0) { }
 
Reply With Quote
  #24 (permalink)  
Old 04-29-2007, 09:16 PM
daniel0012's Avatar
Member
 
Join Date: 11-07-06
Location: Springfield
Posts: 111
iTrader: 0 / 0%
Forget that last post, it was a mistake.
Where do I put var_dump($HTTP_POST_VARS); at?
 
Reply With Quote
  #25 (permalink)  
Old 04-29-2007, 09:37 PM
brealmz's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 04-10-07
Posts: 75
iTrader: 0 / 0%
Code:
<?php if(isset($HTTP_POST_VARS['name-of-your-submit-button'])){ $event = $HTTP_POST_VARS['event']; $date = $HTTP_POST_VARS['date']; $time = $HTTP_POST_VARS['time']; $description = $HTTP_POST_VARS['description']; $file = preg_replace ('/[^a-zA-Z0-9\._-]/', '', $HTTP_POST_VARS['file']); $file = $_SERVER['DOCUMENT_ROOT'].'/event/'.$file; $cont = '<tr><td><b>'.$HTTP_POST_VARS['event'].'</b></td></tr><tr><td>'.$HTTP_POST_VARS['date'].'</td></tr><tr><td>'.$HTTP_POST_VARS['time'].'</td></tr><tr><td style="padding-bottom: 10px;">"'.$HTTP_POST_VARS['description'].'"</td>&nbsp; </tr><br />'; $f = fopen ($file, 'w'); fputs ($f, $cont); fclose ($f); /////remove this if it works just for debbuging purpose echo "FILE-> $file<br />"; var_dump($HTTP_POST_VARS); }//end if.. ?>
Note: Replace with name name of your submit button
__________________
 
Reply With Quote
  #26 (permalink)  
Old 04-29-2007, 09:49 PM
daniel0012's Avatar
Member
 
Join Date: 11-07-06
Location: Springfield
Posts: 111
iTrader: 0 / 0%
I put that code in and it doesn't show anything. I get a blank page.
 
Reply With Quote
  #27 (permalink)  
Old 04-30-2007, 02:43 AM
brealmz's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 04-10-07
Posts: 75
iTrader: 0 / 0%
if(isset($HTTP_POST_VARS['name-of-your-submit-button']))
did you replace it with your submit button name?
when you say blank page is it when you submit the form?
do you still have the error_reporting(E_ALL); at the top of page so we can see all errors.
__________________
 
Reply With Quote
  #28 (permalink)  
Old 04-30-2007, 05:40 AM
daniel0012's Avatar
Member
 
Join Date: 11-07-06
Location: Springfield
Posts: 111
iTrader: 0 / 0%
Ok, here what it displayed
Quote:
Notice: Undefined index: file in /home/scabapti/public_html/test/add/add_event_form.php on line 26
FILE-> /home/scabapti/public_html/event/
array(6) { ["event"]=> string(9) "Something" ["date"]=> string(10) "12/12/1212" ["time"]=> string(5) "12:34" ["description"]=> string(1) "1" ["file_name"]=> string( "12121212" ["submit"]=> string(9) "Add Event" }
By the way, that , is an 8 in parentheses.
 
Reply With Quote
  #29 (permalink)  
Old 04-30-2007, 05:57 AM
brealmz's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 04-10-07
Posts: 75
iTrader: 0 / 0%
$file = preg_replace ('/[^a-zA-Z0-9\._-]/', '', $HTTP_POST_VARS['file']);
must be $HTTP_POST_VARS['file_name']
__________________
 
Reply With Quote
  #30 (permalink)  
Old 04-30-2007, 07:31 AM
daniel0012's Avatar
Member
 
Join Date: 11-07-06
Location: Springfield
Posts: 111
iTrader: 0 / 0%
Quote:
Warning: fopen(/home/scabapti/public_html/event/12121212) [function.fopen]: failed to open stream: Not a directory in /home/scabapti/public_html/test/add/add_event_form.php on line 31

Warning: fputs(): supplied argument is not a valid stream resource in /home/scabapti/public_html/test/add/add_event_form.php on line 32

Warning: fclose(): supplied argument is not a valid stream resource in /home/scabapti/public_html/test/add/add_event_form.php on line 33
FILE-> /home/scabapti/public_html/event/12121212
array(6) { ["event"]=> string(9) "Something" ["date"]=> string(10) "12/12/1212" ["time"]=> string(5) "12:34" ["description"]=> string(1) "1" ["file_name"]=> string( "12121212" ["submit"]=> string(9) "Add Event" }
This is what I got when I changed it.
 
Reply With Quote
  #31 (permalink)  
Old 04-30-2007, 09:50 AM
brealmz's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 04-10-07
Posts: 75
iTrader: 0 / 0%
ok youre almost there.
this is your document root
/home/scabapti/public_html/

you are working here
/home/scabapti/public_html/test/add/
then your event folder was here

replace your $file with this.
$file = $_SERVER['DOCUMENT_ROOT'].'test/add/event/'.$file.'.html';

goodluck and remove this :

echo "FILE-> $file<br />";
var_dump($HTTP_POST_VARS);
__________________
 
Reply With Quote
  #32 (permalink)  
Old 04-30-2007, 12:53 PM
daniel0012's Avatar
Member
 
Join Date: 11-07-06
Location: Springfield
Posts: 111
iTrader: 0 / 0%
I now get this:
Quote:
Warning: fopen(/home/scabapti/public_htmltest/add/event/12121212.html) [function.fopen]: failed to open stream: No such file or directory in /home/scabapti/public_html/test/add/add_event_form.php on line 31

Warning: fputs(): supplied argument is not a valid stream resource in /home/scabapti/public_html/test/add/add_event_form.php on line 32

Warning: fclose(): supplied argument is not a valid stream resource in /home/scabapti/public_html/test/add/add_event_form.php on line 33
 
Reply With Quote
  #33 (permalink)  
Old 04-30-2007, 01:08 PM
brealmz's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 04-10-07
Posts: 75
iTrader: 0 / 0%
lol. im sorry my fault.

$file = $_SERVER['DOCUMENT_ROOT'].'/test/add/event/'.$file.'.html';

im always careless



if you get a file permission error do this(hope not)
chmod("$_SERVER['DOCUMENT_ROOT'].'/test/add/event/'", 755);
before fopen
__________________

Last edited by brealmz; 04-30-2007 at 01:13 PM.
 
Reply With Quote
  #34 (permalink)  
Old 04-30-2007, 01:32 PM
daniel0012's Avatar
Member
 
Join Date: 11-07-06
Location: Springfield
Posts: 111
iTrader: 0 / 0%
Now this:
Quote:
Warning: fopen(/home/scabapti/public_html/test/add/event/12121212.html) [function.fopen]: failed to open stream: No such file or directory in /home/scabapti/public_html/test/add/add_event_form.php on line 31

Warning: fputs(): supplied argument is not a valid stream resource in /home/scabapti/public_html/test/add/add_event_form.php on line 32

Warning: fclose(): supplied argument is not a valid stream resource in /home/scabapti/public_html/test/add/add_event_form.php on line 33
 
Reply With Quote
  #35 (permalink)  
Old 04-30-2007, 01:41 PM
brealmz's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 04-10-07
Posts: 75
iTrader: 0 / 0%
what??? i cant believe it.
ok..
one question. are you sure you create an event folder?
if not create it first.
im little drunk today but thats the only problem i can see.
__________________

Last edited by brealmz; 04-30-2007 at 01:46 PM.
 
Reply With Quote
  #36 (permalink)  
Old 04-30-2007, 01:46 PM
daniel0012's Avatar
Member
 
Join Date: 11-07-06
Location: Springfield
Posts: 111
iTrader: 0 / 0%
/ public_html / test / add / events /
That's the folder.

In the fopen statement, why is the extension html
 
Reply With Quote
  #37 (permalink)  
Old 04-30-2007, 01:59 PM
brealmz's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 04-10-07
Posts: 75
iTrader: 0 / 0%
oh..

$file = $_SERVER['DOCUMENT_ROOT'].'/test/add/events/'.$file.'.html';

you can use any extension like .txt

$file = $_SERVER['DOCUMENT_ROOT'].'/test/add/events/'.$file.'.txt';
__________________
 
Reply With Quote
  #38 (permalink)  
Old 04-30-2007, 02:07 PM
daniel0012's Avatar
Member
 
Join Date: 11-07-06
Location: Springfield
Posts: 111
iTrader: 0 / 0%
SWEET!! It worked. Thank you so much.
 
Reply With Quote
  #39 (permalink)  
Old 03-18-2009, 11:42 PM
Junior Member
 
Join Date: 03-18-09
Posts: 1
iTrader: 0 / 0%
Wink Ali

try this for creating a file. once the file is created use unlink to remove it if needed?

<?php

$file='';
$file=$_GET['msg'] ;
$msg = isset($_GET['msg']) ? htmlspecialchars($_GET['msg']) : ".";
$lines = "<p><font color=grey>$nick says:</font><br><font color=green>$msg</font>";
if (isset($_GET['msg'])){
if (file_exists($file)) {
$f=fopen($file,"a+");
}

else {

$f = fopen($file,"w+");

}

fwrite($f,$lines."\r\n");
fclose($f);

echo $lines;
$flag = file($file);
$content = "";
foreach ($flag as $value) {
$content .= $value;
}
echo "<br>";
echo $content;

you can also ad an extention to the file like txt etc. Also you can use post variable to creat the file using the above Code. Works for me fine. If need any help let me know?
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create 404 file on win server Jalpari Web Hosting Forum 4 11-22-2007 03:47 AM
How to create the cer file for nokia n95 shahab6 Tech Talk 1 09-15-2007 03:49 PM
Create an xml file using php? Arenlor Coding Forum 2 01-12-2007 06:02 PM
How to create an RSS file DarrenC Marketing Forum 4 04-09-2006 12:01 PM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 06:46 PM.
Powered by vBulletin
Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.