Current location: Hot Scripts Forums » Programming Languages » PHP » need help with saving two forms in php


need help with saving two forms in php

Reply
  #1 (permalink)  
Old 09-20-06, 09:09 AM
trinity trinity is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
need help with saving two forms in php

Hi ,
I am new and have 2 forms in html and also i have created database in mysql and the tables in it too ,i have also written the save forms in php for them.But it just gives me a blank page when i click the save button on the forms .
Any help will be really appreciated.
Thanks,
Mallika.
Reply With Quote
  #2 (permalink)  
Old 09-20-06, 09:12 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Post your code.
Reply With Quote
  #3 (permalink)  
Old 09-20-06, 09:17 AM
trinity trinity is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
hi

th?
PHP Code:

include "db.php";


$aname $_POST['aname'];
$adesc $_POST['adesc'];
$aaddr $_POST['aaddr'];
$cname $_POST['cname'];
$caddr $_POST['caddr'];
$cph $_POST['cph'];
$cfax $_POST['cfax'];
$cemail $_POST['cemail'];
$hname $_POST['hname'];
$haddr $_POST['haddr'];
$hph $_POST['hph'];
$hfax $_POST['hfax'];
$hemail $_POST['hemail'];
$ndaward $_POST['ndaward'];

if (
$_POST['gr8_ip_1']) { $gr8_ip_1 "on"; } else { $gr8_ip_1 "off"; }
if (
$_POST['gr8_ip_2']) { $gr8_ip_2 "on"; } else { $gr8_ip_2 "off"; }
if (
$_POST['gr8_ip_3']) { $gr8_ip_3 "on"; } else { $gr8_ip_3 "off"; }
if (
$_POST['gr8_ip_4']) { $gr8_ip_4 "on"; } else { $gr8_ip_4 "off"; }
if (
$_POST['gr8_ip_5']) { $gr8_ip_5 "on"; } else { $gr8_ip_5 "off"; }
if (
$_POST['gr8_ip_6']) { $gr8_ip_6 "on"; } else { $gr8_ip_6 "off"; }
if (
$_POST['gr8_ip_7']) { $gr8_ip_7 "on"; } else { $gr8_ip_7 "off"; }
if (
$_POST['gr8_ip_8']) { $gr8_ip_8 "on"; } else { $gr8_ip_8 "off"; }
if (
$_POST['gr8_ip_9']) { $gr8_ip_9 "on"; } else { $gr8_ip_9 "off"; }
if (
$_POST['gr8_ip_10']) { $gr8_ip_10 "on"; } else { $gr8_ip_10 "off"; }
if (
$_POST['gr8_ip_11']) { $gr8_ip_11 "on"; } else { $gr8_ip_11 "off"; }
if (
$_POST['gr8_ip_12']) { $gr8_ip_12 "on"; } else { $gr8_ip_12 "off"; }

if (
$_POST['gr8_tp_1']) { $gr8_tp_1 "on"; } else { $gr8_tp_1 "off"; }
if (
$_POST['gr8_tp_2']) { $gr8_tp_2 "on"; } else { $gr8_tp_2 "off"; }
if (
$_POST['gr8_tp_3']) { $gr8_tp_3 "on"; } else { $gr8_tp_3 "off"; }
if (
$_POST['gr8_tp_4']) { $gr8_tp_4 "on"; } else { $gr8_tp_4 "off"; }
if (
$_POST['gr8_tp_5']) { $gr8_tp_5 "on"; } else { $gr8_tp_5 "off"; }
if (
$_POST['gr8_tp_6']) { $gr8_tp_6 "on"; } else { $gr8_tp_6 "off"; }
if (
$_POST['gr8_tp_7']) { $gr8_tp_7 "on"; } else { $gr8_tp_7 "off"; }
if (
$_POST['gr8_tp_8']) { $gr8_tp_8 "on"; } else { $gr8_tp_8 "off"; }
if (
$_POST['gr8_tp_9']) { $gr8_tp_9 "on"; } else { $gr8_tp_9 "off"; }
if (
$_POST['gr8_tp_10']) { $gr8_tp_10 "on"; } else { $gr8_tp_10 "off"; }

if (
$_POST['gr9_ip_1']) { $gr9_ip_1 "on"; } else { $gr9_ip_1 "off"; }
if (
$_POST['gr9_ip_2']) { $gr9_ip_2 "on"; } else { $gr9_ip_2 "off"; }
if (
$_POST['gr9_ip_3']) { $gr9_ip_3 "on"; } else { $gr9_ip_3 "off"; }
if (
$_POST['gr9_ip_4']) { $gr9_ip_4 "on"; } else { $gr9_ip_4 "off"; }
if (
$_POST['gr9_ip_5']) { $gr9_ip_5 "on"; } else { $gr9_ip_5 "off"; }
if (
$_POST['gr9_ip_6']) { $gr9_ip_6 "on"; } else { $gr9_ip_6 "off"; }
if (
$_POST['gr9_ip_7']) { $gr9_ip_7 "on"; } else { $gr9_ip_7 "off"; }
if (
$_POST['gr9_ip_8']) { $gr9_ip_8 "on"; } else { $gr9_ip_8 "off"; }
if (
$_POST['gr9_ip_9']) { $gr9_ip_9 "on"; } else { $gr9_ip_9 "off"; }
if (
$_POST['gr9_ip_10']) { $gr9_ip_10 "on"; } else { $gr9_ip_10 "off"; }
if (
$_POST['gr9_ip_11']) { $gr9_ip_11 "on"; } else { $gr9_ip_11 "off"; }
if (
$_POST['gr9_ip_12']) { $gr9_ip_12 "on"; } else { $gr9_ip_12 "off"; }

if (
$_POST['gr9_tp_1']) { $gr9_tp_1 "on"; } else { $gr9_tp_1 "off"; }
if (
$_POST['gr9_tp_2']) { $gr9_tp_2 "on"; } else { $gr9_tp_2 "off"; }

if (
$_POST['gr10_ip_1']) { $gr10_ip_1 "on"; } else { $gr10_ip_1 "off"; }
if (
$_POST['gr10_ip_2']) { $gr10_ip_2 "on"; } else { $gr10_ip_2 "off"; }
if (
$_POST['gr10_ip_3']) { $gr10_ip_3 "on"; } else { $gr10_ip_3 "off"; }
if (
$_POST['gr10_ip_4']) { $gr10_ip_4 "on"; } else { $gr10_ip_4 "off"; }
if (
$_POST['gr10_ip_5']) { $gr10_ip_5 "on"; } else { $gr10_ip_5 "off"; }
if (
$_POST['gr10_ip_6']) { $gr10_ip_6 "on"; } else { $gr10_ip_6 "off"; }
if (
$_POST['gr10_ip_7']) { $gr10_ip_7 "on"; } else { $gr10_ip_7 "off"; }
if (
$_POST['gr10_ip_8']) { $gr10_ip_8 "on"; } else { $gr10_ip_8 "off"; }
if (
$_POST['gr10_ip_9']) { $gr10_ip_9 "on"; } else { $gr10_ip_9 "off"; }
if (
$_POST['gr10_ip_10']) { $gr10_ip_10 "on"; } else { $gr10_ip_10 "off"; }
if (
$_POST['gr10_ip_11']) { $gr10_ip_11 "on"; } else { $gr10_ip_11 "off"; }
if (
$_POST['gr10_ip_12']) { $gr10_ip_12 "on"; } else { $gr10_ip_12 "off"; }

$cont $_POST['cont'];

$Query "INSERT INTO form2 VALUES ('$aname', '$adesc', '$aaddr', '$cname', '$caddr', '$cph', '$cfax', '$cemail', '$hname', '$haddr', '$hph', '$hfax','$hemail', '$ndaward', '$gr8_ip_1', '$gr8_ip_2', '$gr8_ip_3', '$gr8_ip_4', '$gr8_ip_5', '$gr8_ip_6', '$gr8_ip_7', '$gr8_ip_8', '$gr8_ip_9', '$gr8_ip_10', '$gr8_ip_11', '$gr8_ip_12', '$gr8_tp_1', '$gr8_tp_2', '$gr8_tp_3', '$gr8_tp_4', '$gr8_tp_5', '$gr8_tp_6', '$gr8_tp_7', '$gr8_tp_8', '$gr8_tp_9', '$gr8_tp_10', '$gr9_ip_1', '$gr9_ip_2', '$gr9_ip_3', '$gr9_ip_4', '$gr9_ip_5', '$gr9_ip_6', '$gr9_ip_7', '$gr9_ip_8', '$gr9_ip_9', '$gr9_ip_10', '$gr9_ip_11', '$gr9_ip_12', '$gr9_tp_1', '$gr9_tp_2', '$gr10_ip_1', '$gr10_ip_2', '$gr10_ip_3', '$gr10_ip_4', '$gr10_ip_5', '$gr10_ip_6', '$gr10_ip_7', '$gr10_ip_8', '$gr10_ip_9', '$gr10_ip_10', '$gr10_ip_11', '$gr10_ip_12', '$cont')";

$Result mysql_db_query ($DBName$Query);
mysql_close  ($Link);

if (
$Result) {
      print 
"Data saved correctly";
} else {
      print 
"Error Reported on pform2.php<br>";
    print 
"SQL: <b>$Query</b><br>";
    print 
"$DBName$Link$Host<br>";
}

?>e code id here : 

Last edited by nico_swd; 09-20-06 at 09:20 AM.
Reply With Quote
  #4 (permalink)  
Old 09-20-06, 11:04 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
From a syntax standpoint, there is nothing in this code that would prevent it from executing and output one of the if ($Result) {... choices. Either something in the db.php include file is stopping execution or the submit form is not actually causing this PHP code to be executed.

Could you post the db.php file (xxxxxxxx out any sensitive information such as passwords...) and post the form code.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #5 (permalink)  
Old 09-21-06, 07:21 AM
tamil tamil is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Simple method

hi trinity here i give easy methos to this.

in HTML
Code:
   <input type=checkbox name=ch[0] value="First">
   <input type=checkbox name=ch[1] value="Second">
   <input type=checkbox name=ch[2] value="Third">

   <input type=hidden name=num value=3>
in PHP
PHP Code:

    $ch=$_POST["ch"];

    
$num=$_POST["num"];

    for(
$i=0;$i<$num;$i++)
      {
       if(
$ch[$i]) {      echo $i.". is on. value=".$ch[$i]."<br>";  }else
            {
             echo 
$i.". is off<br>";
             }    
      } 

Last edited by nico_swd; 09-21-06 at 07:27 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
Saving php generated file as html file GS300 PHP 0 12-29-04 03:34 AM
PHP to calculate HTML forms jamesian PHP 1 10-25-04 07:45 AM
Need a PHP Programmer to make forms. LiQuid2o Job Offers & Assistance 10 08-13-04 12:49 AM
Forms and php? move3rd PHP 2 04-01-04 06:38 PM


All times are GMT -5. The time now is 07:29 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.