gsanghera Posted December 19, 2007 Share Posted December 19, 2007 ok, i am a utter and total newbie I'm trying to display some data which works, and have one box (auth_no) where the person can enter data to update to the database. I'm hacking code, dont know PHP too much, If i could get some help it would be appreciated. here is what i have basically they come to this screen from another screen based on the Id from where they were. here they will see a list of arranged payments. each payment needs to have an authorization entered and updated on the date of the payment. i cant get my button to work or update to the DB DB is MYSQL i also get teh follwoing error on the browser page Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\tcs\auth_no11.php:10) in C:\xampp\htdocs\tcs\auth_no11.php on line 24 CODE BELOW <HTML> <HEAD> <meta http-equiv="Content-Language" content="en-us"> <TITLE>This is Example</TITLE></HEAD> <body> <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#77a7ad cellSpacing=1 cellPadding=1 width="100%" bgColor=#ffffff border=1> <tr> <td width="37" align="center" ><font face="Tahoma" size="2"><b>STT</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Payment ID</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>debtor_id</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Type</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Payment_date</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Fee</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Nsf</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Payment_Amount</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Total Payment</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Auth_no</b></font></td> </tr> <? include_once("config.php"); session_start(); $userinfo=$_SESSION; if($userinfo['islogged'] & $userinfo['accesslevel'] >= 10){ $todo=$_POST['todo']; if(isset($_GET['id'])){ $id=$_GET['id']; }elseif(isset($_POST['id'])){ $id=$_POST['id']; } } $update=$_POST['update']; $query="select id,debtor_id,type,payment_date,fees,nsf,payment_amount, total_payment,auth_no from tcs_process where debtor_id='$id' and verified=0 order by payment_date "; $result=mysql_query($query); if($array=mysql_fetch_assoc($result)){ $debtor_id=$id; $payment_id=$array['id']; $type=$array['type']; $payment_date=$array['payment_date']; $fees=$array['fees']; $nsf=$array['nsf']; $payment_amount=$array['payment_amount']; $total_payment=$array['total_payment']; $auth_no=$_POST['auth_no']; $search_id=$array['id']; if($_POST['mod_user']=="Update"){ $debtor_id=$id; $payment_id=$array['paymentid']; $type=$array['type']; $payment_date=$array['payment_date']; $fees=$array['fees']; $nsf=$array['nsf']; $payment_amount=$array['payment_amount']; $total_payment=$array['total_payment']; $auth_no=$_POST['auth_no']; $update_query="UPDATE tcs_process SET auth_no='$auth_no' where paymentid='$payment_id'"; $update_result=mysql_query($update_query) or die(mysql_error()); $error_code="Updated Information"; } } { $stt=0; while($row=mysql_fetch_array($result)) { $stt++; ?> <tr> <td width="37" align="center"><font face="Tahoma" size="2"><?=$stt?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["id"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["debtor_id"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["type"]?></font></td> <td align="cener"><font face="Tahoma" size="2"><?=$row["payment_date"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["fees"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["nsf"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["payment_amount"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["total_payment"]?></font></td> <td><label><input name="auth_no" type="text" size="20" /></label></td> <td><label><? if($search_name=='newuser'){ print "<input type='submit' name='mod_user' id='mod_user' value='Add'>"; }else{ print "<input type='submit' name='mod_user' id='mod_user' value='Update'"; } ?> </tr> <? } } ?> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 19, 2007 Share Posted December 19, 2007 Session_start(); has to be on the first line of your page. <?php session_start(); ?> <HTML> <HEAD> <meta http-equiv="Content-Language" content="en-us"> <TITLE>This is Example</TITLE></HEAD> <body> <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#77a7ad cellSpacing=1 cellPadding=1 width="100%" bgColor=#ffffff border=1> <tr> <td width="37" align="center" ><font face="Tahoma" size="2">STT</font></td> <td align="center" ><font face="Tahoma" size="2">Payment ID</font></td> <td align="center" ><font face="Tahoma" size="2">debtor_id</font></td> <td align="center" ><font face="Tahoma" size="2">Type</font></td> <td align="center" ><font face="Tahoma" size="2">Payment_date</font></td> <td align="center" ><font face="Tahoma" size="2">Fee</font></td> <td align="center" ><font face="Tahoma" size="2">Nsf</font></td> <td align="center" ><font face="Tahoma" size="2">Payment_Amount</font></td> <td align="center" ><font face="Tahoma" size="2">Total Payment</font></td> <td align="center" ><font face="Tahoma" size="2">Auth_no</font></td> </tr> <? include_once("config.php"); $userinfo=$_SESSION; if($userinfo['islogged'] & $userinfo['accesslevel'] >= 10){ $todo=$_POST['todo']; if(isset($_GET['id'])){ $id=$_GET['id']; }elseif(isset($_POST['id'])){ $id=$_POST['id']; } } $update=$_POST['update']; $query="select id,debtor_id,type,payment_date,fees,nsf,payment_amount, total_payment,auth_no from tcs_process where debtor_id='$id' and verified=0 order by payment_date "; $result=mysql_query($query); if($array=mysql_fetch_assoc($result)){ $debtor_id=$id; $payment_id=$array['id']; $type=$array['type']; $payment_date=$array['payment_date']; $fees=$array['fees']; $nsf=$array['nsf']; $payment_amount=$array['payment_amount']; $total_payment=$array['total_payment']; $auth_no=$_POST['auth_no']; $search_id=$array['id']; if($_POST['mod_user']=="Update"){ $debtor_id=$id; $payment_id=$array['paymentid']; $type=$array['type']; $payment_date=$array['payment_date']; $fees=$array['fees']; $nsf=$array['nsf']; $payment_amount=$array['payment_amount']; $total_payment=$array['total_payment']; $auth_no=$_POST['auth_no']; $update_query="UPDATE tcs_process SET auth_no='$auth_no' where paymentid='$payment_id'"; $update_result=mysql_query($update_query) or die(mysql_error()); $error_code="Updated Information"; } } { $stt=0; while($row=mysql_fetch_array($result)) { $stt++; ?> <tr> <td width="37" align="center"><font face="Tahoma" size="2"><?=$stt?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["id"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["debtor_id"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["type"]?></font></td> <td align="cener"><font face="Tahoma" size="2"><?=$row["payment_date"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["fees"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["nsf"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["payment_amount"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["total_payment"]?></font></td> <td><label><input name="auth_no" type="text" size="20" /></label></td> <td><label><? if($search_name=='newuser'){ print "<input type='submit' name='mod_user' id='mod_user' value='Add'>"; }else{ print "<input type='submit' name='mod_user' id='mod_user' value='Update'"; } ?> </tr> <? } } ?> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
gsanghera Posted December 19, 2007 Author Share Posted December 19, 2007 Thank you for that. That's one problem solved. your help on that one was so very much appreciated. Only the button issue to go Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 19, 2007 Share Posted December 19, 2007 Try <?php session_start(); ?> <HTML> <HEAD> <meta http-equiv="Content-Language" content="en-us"> <TITLE>This is Example</TITLE></HEAD> <body> <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#77a7ad cellSpacing=1 cellPadding=1 width="100%" bgColor=#ffffff border=1> <tr> <td width="37" align="center" ><font face="Tahoma" size="2">STT</font></td> <td align="center" ><font face="Tahoma" size="2">Payment ID</font></td> <td align="center" ><font face="Tahoma" size="2">debtor_id</font></td> <td align="center" ><font face="Tahoma" size="2">Type</font></td> <td align="center" ><font face="Tahoma" size="2">Payment_date</font></td> <td align="center" ><font face="Tahoma" size="2">Fee</font></td> <td align="center" ><font face="Tahoma" size="2">Nsf</font></td> <td align="center" ><font face="Tahoma" size="2">Payment_Amount</font></td> <td align="center" ><font face="Tahoma" size="2">Total Payment</font></td> <td align="center" ><font face="Tahoma" size="2">Auth_no</font></td> </tr> <?php include_once("config.php"); $userinfo=$_SESSION; if($userinfo['islogged'] & $userinfo['accesslevel'] >= 10){ $todo=$_POST['todo']; if(isset($_GET['id'])){ $id=$_GET['id']; }elseif(isset($_POST['id'])){ $id=$_POST['id']; } } $update=$_POST['update']; $query="select id,debtor_id,type,payment_date,fees,nsf,payment_amount, total_payment,auth_no from tcs_process where debtor_id='$id' and verified=0 order by payment_date "; $result=mysql_query($query); if($array=mysql_fetch_assoc($result)){ $debtor_id=$id; $payment_id=$array['id']; $type=$array['type']; $payment_date=$array['payment_date']; $fees=$array['fees']; $nsf=$array['nsf']; $payment_amount=$array['payment_amount']; $total_payment=$array['total_payment']; $auth_no=$_POST['auth_no']; $search_id=$array['id']; if(isset($_POST['mod_user'])){ $debtor_id=$id; $payment_id=$array['paymentid']; $type=$array['type']; $payment_date=$array['payment_date']; $fees=$array['fees']; $nsf=$array['nsf']; $payment_amount=$array['payment_amount']; $total_payment=$array['total_payment']; $auth_no=$_POST['auth_no']; $update_query="UPDATE tcs_process SET auth_no='$auth_no' where paymentid='$payment_id'"; $update_result=mysql_query($update_query) or die(mysql_error()); $error_code="Updated Information"; } } { $stt=0; while($row=mysql_fetch_array($result)) { $stt++; ?> <tr> <td width="37" align="center"><font face="Tahoma" size="2"><?=$stt?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["id"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["debtor_id"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["type"]?></font></td> <td align="cener"><font face="Tahoma" size="2"><?=$row["payment_date"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["fees"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["nsf"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["payment_amount"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["total_payment"]?></font></td> <td><label><input name="auth_no" type="text" size="20" /></label></td> <td><label><? if($search_name=='newuser'){ print "<input type='submit' name='mod_user' id='mod_user' value='Add'>"; }else{ print "<input type='submit' name='mod_user' id='mod_user' value='Update'"; } ?> </tr> <? } } ?> Quote Link to comment Share on other sites More sharing options...
gsanghera Posted December 19, 2007 Author Share Posted December 19, 2007 The Error is gone, but still no luck on getting the button to work. anything i need to post that can help you? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 19, 2007 Share Posted December 19, 2007 Its because you forgot ">" for your button. Try <?php session_start(); ?> <HTML> <HEAD> <meta http-equiv="Content-Language" content="en-us"> <TITLE>This is Example</TITLE></HEAD> <body> <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#77a7ad cellSpacing=1 cellPadding=1 width="100%" bgColor=#ffffff border=1> <tr> <td width="37" align="center" ><font face="Tahoma" size="2">STT</font></td> <td align="center" ><font face="Tahoma" size="2">Payment ID</font></td> <td align="center" ><font face="Tahoma" size="2">debtor_id</font></td> <td align="center" ><font face="Tahoma" size="2">Type</font></td> <td align="center" ><font face="Tahoma" size="2">Payment_date</font></td> <td align="center" ><font face="Tahoma" size="2">Fee</font></td> <td align="center" ><font face="Tahoma" size="2">Nsf</font></td> <td align="center" ><font face="Tahoma" size="2">Payment_Amount</font></td> <td align="center" ><font face="Tahoma" size="2">Total Payment</font></td> <td align="center" ><font face="Tahoma" size="2">Auth_no</font></td> </tr> <?php include_once("config.php"); $userinfo=$_SESSION; if($userinfo['islogged'] & $userinfo['accesslevel'] >= 10){ $todo=$_POST['todo']; if(isset($_GET['id'])){ $id=$_GET['id']; }elseif(isset($_POST['id'])){ $id=$_POST['id']; } } $update=$_POST['update']; $query="select id,debtor_id,type,payment_date,fees,nsf,payment_amount, total_payment,auth_no from tcs_process where debtor_id='$id' and verified=0 order by payment_date "; $result=mysql_query($query); if($array=mysql_fetch_assoc($result)){ $debtor_id=$id; $payment_id=$array['id']; $type=$array['type']; $payment_date=$array['payment_date']; $fees=$array['fees']; $nsf=$array['nsf']; $payment_amount=$array['payment_amount']; $total_payment=$array['total_payment']; $auth_no=$_POST['auth_no']; $search_id=$array['id']; if(isset($_POST['mod_user'])){ $debtor_id=$id; $payment_id=$array['paymentid']; $type=$array['type']; $payment_date=$array['payment_date']; $fees=$array['fees']; $nsf=$array['nsf']; $payment_amount=$array['payment_amount']; $total_payment=$array['total_payment']; $auth_no=$_POST['auth_no']; $update_query="UPDATE tcs_process SET auth_no='$auth_no' where paymentid='$payment_id'"; $update_result=mysql_query($update_query) or die(mysql_error()); $error_code="Updated Information"; } } { $stt=0; while($row=mysql_fetch_array($result)) { $stt++; ?> <tr> <td width="37" align="center"><font face="Tahoma" size="2"><?=$stt?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["id"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["debtor_id"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["type"]?></font></td> <td align="cener"><font face="Tahoma" size="2"><?=$row["payment_date"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["fees"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["nsf"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["payment_amount"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["total_payment"]?></font></td> <td><label><input name="auth_no" type="text" size="20" /></label></td> <td><label><?php if($search_name=='newuser'){ print "<input type='submit' name='mod_user' id='mod_user' value='Add'>"; }else{ print "<input type='submit' name='mod_user' id='mod_user' value='Update'>"; } ?> </tr> <? } } ?> Quote Link to comment Share on other sites More sharing options...
gsanghera Posted December 19, 2007 Author Share Posted December 19, 2007 Still no luck CLick button, nothing happening. wow i suck at this. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 19, 2007 Share Posted December 19, 2007 Still no luck CLick button, nothing happening. wow i suck at this. Where is the form? btw, stop using <? ?> thats the old PHP, its weak coding, and might lead to security issues. Quote Link to comment Share on other sites More sharing options...
gsanghera Posted December 20, 2007 Author Share Posted December 20, 2007 i dont undersatnd what you mean by where is the form. also what should i replace the ?> and <? with? thanks again Quote Link to comment Share on other sites More sharing options...
revraz Posted December 20, 2007 Share Posted December 20, 2007 You need a FORM and /FORM tags in order to submit something. This tells it what method to use and what action to take. Replace <? with <?php i dont undersatnd what you mean by where is the form. also what should i replace the ?> and <? with? thanks again Quote Link to comment Share on other sites More sharing options...
Jessica Posted December 20, 2007 Share Posted December 20, 2007 The problem is in your HTML, not PHP. As revras said, you need a form element. Here's a good tutorial: http://www.tizag.com/htmlT/forms.php Quote Link to comment Share on other sites More sharing options...
gsanghera Posted December 21, 2007 Author Share Posted December 21, 2007 Thanks all for your help. thanks for the link jesirose i'll se what i can do. the code now reads.. as follows the button does something, but cant get the data to update now usimg the query.. $update_query="UPDATE tcs_process SET auth_no='$auth_no' WHERE id='$payment_id'"; <? session_start();?> <HTML> <HEAD> <meta http-equiv="Content-Language" content="en-us"> <TITLE>This is Example</TITLE></HEAD> <body> <?php if(isset($_GET['id'])){ $id=$_GET['id']; }elseif(isset($_POST['id'])){ $id=$_POST['id']; } ?> <form method="post" action="auth_no11.php?id=<?php echo $id ?>"> <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#77a7ad cellSpacing=1 cellPadding=1 width="100%" bgColor=#ffffff border=1> <tr> <td width="37" align="center" ><font face="Tahoma" size="2"><b>STT</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Payment ID</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>debtor_id</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Type</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Payment_date</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Fee</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Nsf</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Payment_Amount</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Total Payment</b></font></td> <td align="center" ><font face="Tahoma" size="2"><b>Auth_no</b></font></td> </tr> <? include_once("config.php"); $userinfo=$_SESSION; if($userinfo['islogged'] & $userinfo['accesslevel'] >= 10){ $todo=$_POST['todo']; if(isset($_GET['id'])){ $id=$_GET['id']; }elseif(isset($_POST['id'])){ $id=$_POST['id']; } } $update=$_POST['update']; $query="select id,debtor_id,type,payment_date,fees,nsf,payment_amount, total_payment,auth_no from tcs_process where debtor_id='$id' and verified=0 order by payment_date "; $result=mysql_query($query); if($array=mysql_fetch_assoc($result)){ $debtor_id=$id; $payment_id=$array['paymentid']; $type=$array['type']; $payment_date=$array['payment_date']; $fees=$array['fees']; $nsf=$array['nsf']; $payment_amount=$array['payment_amount']; $total_payment=$array['total_payment']; $auth_no=$_POST['auth_no']; $search_id=$array['id']; if($_POST['mod_user']=="Update"){ $debtor_id=$id; $payment_id=$array['paymentid']; $type=$array['type']; $payment_date=$array['payment_date']; $fees=$array['fees']; $nsf=$array['nsf']; $payment_amount=$array['payment_amount']; $total_payment=$array['total_payment']; $auth_no=$_POST['auth_no']; echo $auth_no; $update_query="UPDATE tcs_process SET auth_no='$auth_no' WHERE id='$payment_id'"; echo $update_query . "<br />"; $update_result=mysql_query($update_query) or die(mysql_error()); $error_code="Updated Information"; } } { $stt=0; while($row=mysql_fetch_array($result)) { $stt++; ?> <tr> <td width="37" align="center"><font face="Tahoma" size="2"><?=$stt?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["id"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["debtor_id"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["type"]?></font></td> <td align="cener"><font face="Tahoma" size="2"><?=$row["payment_date"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["fees"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["nsf"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["payment_amount"]?></font></td> <td align="center"><font face="Tahoma" size="2"><?=$row["total_payment"]?></font></td> <td><label><input name="auth_no" type="text" size="20" /></label></td> <td><label><? if($search_name=='newuser'){ print "<input type='submit' name='mod_user' id='mod_user' value='Add'>"; }else{ print "<input type='submit' name='mod_user' id='mod_user' value='Update'"; } ?> </tr> <? } } ?> </table> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.