Jump to content

scrappy1855

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

scrappy1855's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have a Php file that processes my form data into a csv file after that is complete i need to execute a vbscript file that will loop through all of the form submissions and processes them along with an access vba process. But i'm having issues executing the vbs file from my php file. Here is my code posted below. The vbscript resides on my webserver folder but really i'd like to if able launch it from a network drive. Any assistance woudl be greatly appreciated. <?php if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; $customernumber = $_POST["customernumber"]; $yearwkstart = $_POST["yearwkstart"]; $yearwkend = $_POST["yearwkend"]; $email = $_POST["email"]; $num=''; do{ $file = 'c:\asys_reports\baddebtfiles\baddebt'.$num.'.csv'; }while(file_exists($file) && $num-->intval(PHP_INT_MAX+1)); $values = "$customernumber\r\n$yearwkstart\r\n$yearwkend\r\n$email\r\n"; IF (!isset($_POST["customernumber"])) { header('Location: '.$uri.'/index_files/baddebtquery.htm'); } elseif (empty($customernumber) || empty($yearwkstart) || empty($yearwkend) || empty($email)) { header('Location: '.$uri.'/index_files/error.htm'); } else { $values = "$customernumber,$yearwkstart,$yearwkend,$email,"; $fp = fopen($file, "w") or die("Couldn't open $file for writing!"); $numBytes = fwrite($fp, $values) or die("Couldn't write values to file!"); fclose($fp); Echo Exec('baddebtfiles.vbs') header('Location: '.$uri.'/index_files/complete.htm'); } ?>
  2. I found another acceptable solution that did exactly what i wanted. Thank you to everyone for the help its been greatly appreciated. Here's the working code: <?php error_reporting(E_ALL); ini_set("display_errors", 1); $customernumber = $_POST["customernumber"]; $yearwkstart = $_POST["yearwkstart"]; $yearwkend = $_POST["yearwkend"]; $email = $_POST["email"]; $num=''; do{ $file = 'c:\asys_reports\baddebt'.$num.'.txt'; }while(file_exists($file) && $num-->intval(PHP_INT_MAX+1)); $values = "$customernumber\r\n$yearwkstart\r\n$yearwkend\r\n$email\r\n"; IF (!isset($_POST["customernumber"])) { if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/index_files/baddebtquery.htm'); } elseif (empty($customernumber) || empty($yearwkstart) || empty($yearwkend) || empty($email)) { if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/index_files/error.htm'); } else { $values = "$customernumber\r\n$yearwkstart\r\n$yearwkend\r\n$email\r\n"; $fp = fopen($file, "w") or die("Couldn't open $file for writing!"); $numBytes = fwrite($fp, $values) or die("Couldn't write values to file!"); fclose($fp); if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/index_files/complete.htm'); } ?>
  3. I'm can't seem to find anything on filename handling in php . I am needing to not append to my baddebt.txt file but create a new baddebt-1.txt, baddebt-2.txt, baddebt-3.txt depending on how many queries are submitted. I was hoping that i could get some advice. Here is my code that is now working thanks to some other help on this forum. However i realized another problem for if someone submits 2 queries in a row it won't be able to handle creation of multiple txt files. <?php error_reporting(E_ALL); ini_set("display_errors", 1); $customernumber = $_POST["customernumber"]; $yearwkstart = $_POST["yearwkstart"]; $yearwkend = $_POST["yearwkend"]; $email = $_POST["email"]; $file = "c:\asys_reports\baddebt.txt"; $values = "$customernumber\r\n$yearwkstart\r\n$yearwkend\r\n$ email\r\n"; IF (!isset($_POST["customernumber"])) { if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/index_files/baddebtquery.htm'); } elseif (empty($customernumber) || empty($yearwkstart) || empty($yearwkend) || empty($email)) { if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/index_files/error.htm'); } else { $values = "$customernumber\r\n$yearwkstart\r\n$yearwkend\r\n$ email\r\n"; $fp = fopen($file, "w") or die("Couldn't open $file for writing!"); $numBytes = fwrite($fp, $values) or die("Couldn't write values to file!"); fclose($fp); echo exec( if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/index_files/complete.htm'); } ?> [\PHP]
  4. Here is my code now... Its fixed mostly now. When any of the fields are missing then it goes to the Error page, and when all fields are correctly filled in then it goes to txt file correctly. I was really wanting it to just reload page if nothing was entered whatsoever. It is perfectly fine for me to go to error page when nothing is submitted as long as it doesn't create txt file. Thank you for all of your help. Next thing agenda is to add user authentication so that only 2 users can run the query. Back to Research. <?php $customernumber = $_POST["customernumber"]; $yearwkstart = $_POST["yearwkstart"]; $yearwkend = $_POST["yearwkend"]; $email = $_POST["email"]; $file = "c:\asys_reports\baddebt.txt"; $values = "$customernumber\r\n$yearwkstart\r\n$yearwkend\r\n$ email\r\n"; IF (!isset($_POST["customernumber"])) { if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/index_files/baddebtquery.htm'); } elseif (empty($customernumber) || empty($yearwkstart) || empty($yearwkend) || empty($email)) { if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/index_files/error.htm'); } else { $values = "$customernumber\r\n$yearwkstart\r\n$yearwkend\r\n$ email\r\n"; $fp = fopen($file, "w") or die("Couldn't open $file for writing!"); $numBytes = fwrite($fp, $values) or die("Couldn't write values to file!"); fclose($fp); if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/index_files/complete.htm'); } ?>
  5. baddebt.php is the script file, its just going straight to page cannot be displayed. If i clear out all the validation and put back in just the original part , it works just fine. Kinda strange, I'm hoping its just some little tweak that i can't locate. It is not outputting anything at all.
  6. Well what i'm trying to get it to do , is if the form is blank when submitted to reload the page , and if any of the fields have empty values to give them an error page, and then if all fields are correctly filled in, then proceed with creating the txt file and give them the completed page. However it doesn't seem to even start the validation. All 3 methods go straight to http://websiteurl/index_files/baddebt.php and say page cannot be displayed. BTW: I changed IF to if and same thing.
  7. I am New to php and trying to get a form to create a text file from results. I actually got the form to work correctly with this ... <?php $customernumber = $_POST["customernumber"]; $yearwkstart = $_POST["yearwkstart"]; $yearwkend = $_POST["yearwkend"]; $email = $_POST["email"]; $file = "c:\asys_reports\baddebt.txt"; $values = "$customernumber\r\n$yearwkstart\r\n$yearwkend\r\n$email\r\n"; $fp = fopen($file, "w") or die("Couldn't open $file for writing!"); $numBytes = fwrite($fp, $values) or die("Couldn't write values to file!"); fclose($fp); if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/index_files/page2424.htm'); ?> However i'm trying to create some validation on the form and getting hung up. Here is my code... Any advise would be greatly appreciated. <?php $customernumber = $_POST["customernumber"]; $yearwkstart = $_POST["yearwkstart"]; $yearwkend = $_POST["yearwkend"]; $email = $_POST["email"]; $file = "c:\asys_reports\baddebt.txt"; $values = "$customernumber\r\n$yearwkstart\r\n$yearwkend\r\n$email\r\n"; IF (!isset($_POST["customernumber"])) { header( "Location: http://websiteurl/index_files/query.htm" ); } elseif (empty($customernumber) || empty($yearwkstart) || empty($yearwkend) || empty($email)) { header( "Location: http://websiteurl/index_files/error.htm" ); } else { $values = "$customernumber\r\n$yearwkstart\r\n$yearwkend\r\n$email\r\n"; $fp = fopen($file, "w") or die("Couldn't open $file for writing!"); $numBytes = fwrite($fp, $values) or die("Couldn't write values to file!"); fclose($fp); if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/index_files/complete.htm'); ?>
×
×
  • 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.