PHP - writing to text file

Asked By rahat baloch
19-Aug-10 07:40 AM
What I am doing wrong here?

<?
session_start();
include("include/functions.php");
if(isset($_POST['Submit'])){
$card_name=isset($_POST['cname']);
$order_address=isset($_POST['address']);
$order_total=isset($_POST['total']);
$order_cc=isset($_POST['cc']);
$handle = fopen("files/orders.txt","w+");
fwrite($handle,"FullName=$card_name Address=$order_address Total=$order_total CreditCard=$order_cc \n");

//$max=count($_SESSION['cart']);
//$handle = fopen("files/orders.txt","w+");

//for($i=0;$i<$max;$i++){
//  $pid=$_SESSION['cart'][$i]['productid'];
//  $q=$_SESSION['cart'][$i]['qty'];
//  $pname=$_SESSION['cart'][$i]['name'];
//  $price=$_SESSION['cart'][$i]['price'];
//
// fwrite($handle,"ID=$pid Quantity=$q Price=$price ProductName=$pname FullName=$card_name Address=$order_address Total=$order_total
//
//CreditCard=$order_cc  \n");

//}

fclose($handle);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Bikes Online : Products | Bikes</title>
<link href="styles/bikes-club.css" rel="stylesheet" type="text/css" />

</head>
<body>
<a name="top"></a>
<div id="masthead">
<h2 id="logo">Bikes Online</h2>
</div>

<?php include("Library/navbar.php");?><div id="container">
    <div style="margin:0px auto;" >
    <div style="padding-bottom:10px">
      <h1 align="center">Place Order</h1>
    </div>

<p><span class="copy">Please enter your Credit Card Details and shipping address below </span></p>
<?php if (!isset($_POST['Submit'])){?>
    <form action="thanks.php" method="post" name="shipform">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="31%">Card Holder Name</td>
        <td width="62%"><input type="text" name="cname" id="fname" /></td>
        <td width="7%">&nbsp;</td>
      </tr>
      <tr>
        <td>Credit Card Type</td>
        <td><input type="text" name="card_type" id="lmane" /></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>ICradit Card Number</td>
        <td><input name="cc" type="text" id="cc" size="40" /></td>
        <td>&nbsp;</td>
      </tr>
    
<tr>
        <td>Address</td>
        <td><input name="address" type="text" id="address" size="40" /></td>
        <td>&nbsp;</td>
      </tr>
<tr>
<td>Total</td>
        <td><input name="total" type="text" id="total" size="40"/></td>
        <td>&nbsp;</td>
      </tr>

      <tr>
        <td>&nbsp;</td>
        <td><input type="submit" name="Submit" id="Submit" value="Confirm Order" /></td>
        <td>&nbsp;</td>
      </tr>

      <tr>
        <td></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      </table>
</FORM>
<?php
   }else{
    ?>
    <tr>
    <td>
<?php echo "ERROR"; ?>

    </td>

    </tr>

<?php } ?>

 </div>
</div>
<div id="sidebar">
  <h4>Bikes Online Registration</h4>
  <p> <a href="index.htm">Join today &raquo;</a></p>
  <h4>First  Bikes Conference</h4>
  <p>Attend the first International Bikes Conference hosted by the Bikes Online Club</p>
  <a href="index.htm">Register today &raquo;</a> </div>
<!--end content -->
<div id="footer"><!--#include virtual="Library\copyright.shtml"-->
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&

nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Last Modified <!--#flastmod file="products.shtml"-->
</div>
</body>
</html>

  Super Man replied to rahat baloch
19-Aug-10 08:32 AM

what problem you are getting.

i think file content part should be like this :


   

= "Name:".$_POST["name"]." Address:".$_POST["address"];

  rahat baloch replied to Super Man
19-Aug-10 09:03 AM
it is not writing on text file.
  Gayathri S replied to rahat baloch
01-Sep-10 09:20 AM
Why are you using isset for everything and then writing it to the file ? Remove the isset and then try writing. It will work.
Create New Account
help
data gets rounded up !!! Excel I have devised a workbook where I enter the credit card details of the transactions received at my hospital for people who pay by credit card. In this there is one column where I enter the credit card number. This cell I have given a general format, text format and a number format Discussions Excel (1) Try creating a custom number format. . . if it is always 12 digit credit card numbers try or if you do not want the dashes just type # 12 times
formulas Excel HELP! is this possible?. . I need a formula, so if a cell shows "Credit Card" then a row appears with areas for the credit card details, but if the cell doesn't show "Credit Card" then the row stays hidden. Not sure if this makes sense, what I want is a row to appear where the user can input their credit card number, name etc. but the row to stay hidden if the paying by an
encrypt credit card details within SQL 2000 / 2005 SQL Server Hi, I am hoping someone could shed some light on encrypting columns within database tables. What I need to do is encrypt the credit card field of a sql table. What is the best way of going about this? This utility XP's like this: http: / / www.sqlservercentral.com / columnists / mcoles / sql2000dbatoolkitpart1.asp keywords: encrypt, credit, card, details, within, SQL, 2000 / 2005 description: Hi, I am hoping someone could shed some light on
How to reprint credit card receipts Windows Server Hello, I processed a credit card sale this morning and when I went to print the credit card recepit for the customer to sign my computer blue screened. Now I cannot find a way to go back in and reprint that credit card slip. Can somebody tell me how to do this? Thank you. Matt - - http: / / www.mattlydy
Node(s) for Loding Credit Card info using eConnect? DataBase We use the "Payables Transaction Entry" & "Payables Transaction Entry Distribution" screens to load Credit Card data. We can get the data in a spreadsheet and wish to load them directly using eConnect. Can someone point me to the node or nodes for loading this Credit Card data into GP 9.0 using eConnect? Great Plains Discussions _NextPart_ (1) DQogICAgICAgICAgICA (1) EConnect RE (1) Content (1) KICAgICAgICAgICAgPENIRUtOTUJSPjIwMDEwPC (1) NOTE (1) DavidM: If you are looking to populate credit card type of information on a payment right on the invoice - you would look at these