writing to text file

Asked By rahat baloch
19-Aug-10 07:40 AM
Earn up to 0 extra points for answering this tough question.
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>

  re: writing to text file

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"];

  re: writing to text file

rahat baloch replied to Super Man
19-Aug-10 09:03 AM
it is not writing on text file.

  re: writing to 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