Trying to get a Form to work

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

38 Replies - 1945 Views - Last Post: 27 November 2008 - 01:31 PM Rate Topic: -----

#1 shygirl15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 21-November 08

Trying to get a Form to work

Posted 22 November 2008 - 09:14 AM

<?php
	ini_set('display_errors','1');

	$username="151296";
	$password="puppypuppy";
	$database="151296";

	$connect=mysql_connect(localhost,$username,$password) or die("error!! ".mysql_error());
	mysql_select_db($database) or die( "Unable to select database");

	$last = $_COOKIE['ID_my_site'];

	$query = "SELECT * FROM wings, users where wings.Numero = users.Wing AND users.username = '" . $last ."';";

	$query2 = "SELECT Wing From users where users.Wing = 0;";

	$result = mysql_query($query);
	$result2 = mysql_query($query2);


	/*<!----soooooo lost----------->*/

	$sql = "INSERT INTO wings (CC1, GB1, Radar1, Runway1, Factory1, NP1, Residence1, PP1, Oil1)
VALUES ($_POST[1], $_POST[2], $_POST[3], $_POST[4], $_POST[5], $_POST[6], $_POST[7], $_POST[8]);";

print "Test this sql query in PHPMYADMIN: ".$sql." <br>"; //

	$result = mysql_query($sql)or die ("Error. Could not do SQL query!");
	/*<!---form starts here--->*/
	?>

	<form action="?" method="post">

	<input style="font-size:8pt;" type=submit name=cons value=Construct onclick="Go(1,this.form);">
	/
	<input style="font-size:8pt;" type=button name=dest value=Destroy onclick="Go(0,this.form);"> buildings to highlighted sector


	<table border=1 bordercolor=#003399 cellspacing=0 width=95%>
	<tr align=center bgcolor=#003399>
	<td><font size=1>Name</td>
	<td><font size=1>Hit<br>Point</td>
	<td><font size=1>Armor</td>
	<td><font size=1>Price<td wrap=><font size=1>Amount</td>
	<td><font size=1>Description</td>
	<td><font size=1>Dependency</td>
	</tr>
			

	<tr align=center>
	<td><font size=1>Command Center</td>
	<td><font size=1>2200</td>
	<td><font size=1>25</td>
	<td><font size=1>10000</td>
	<td nowrap>
	<img border=0 src=up.gif onclick="UpDown(2,1);">

	<input type=text name=1 size=3 maxlength=3 value=0></imput>

	<img border=0 src=down.gif onclick="UpDown(2,0);">
	</td>
	<td><font size=1>Defensive structures and aircraft controlled by computer can attack enemy</td>
	<td><font size=1> </td>
	</tr>

	<tr align=center>
	<td><font size=1>Government Bldg.</td>
	<td><font size=1>1500</td>
	<td><font size=1>20</td>
	<td><font size=1>9000</td>
	<td nowrap>
	<img border=0 src=up.gif onclick="UpDown(3,1);">


	<input type=text name=2 size=3 maxlength=3 value=0></imput>

	<img border=0 src=down.gif onclick="UpDown(3,0);">
	</td>
	<td><font size=1>Collect tax from residence, 100 credits per residence</td>
	<td><font size=1> </td>
	</tr>

	<tr align=center>
	<td><font size=1>Radar Station</td>
	<td><font size=1>500</td>
	<td><font size=1>25</td>
	<td><font size=1>3000</td>
	<td nowrap>
	<img border=0 src=up.gif onclick="UpDown(4,1);">
	<input type=text name=3 size=3 maxlength=3 value=0></imput>
	<img border=0 src=down.gif onclick="UpDown(4,0);">
	</td>
	<td><font size=1>Your wing radar while in base</td>
	<td><font size=1>Power Plant/Nuclear Power Plant</td>
	</tr>

	<tr align=center>
	<td><font size=1>Runway</td>
	<td><font size=1>350</td>
	<td><font size=1>5</td>
	<td><font size=1>1000</td>
	<td nowrap>
	<img border=0 src=up.gif onclick="UpDown(5,1);">
	<input type=text name=4 size=3 maxlength=3 value=0></imput>
	<img border=0 src=down.gif onclick="UpDown(5,0);">
	</td>
	<td><font size=1>Needed for your aircraft to take off</td>
		<td><font size=1></td>
	</tr>
					

	<tr align=center>
		<td><font size=1>Factory</td>
		<td><font size=1>800</td>
		<td><font size=1>10</td>
		<td><font size=1>1000</td>
		<td nowrap>
			<img border=0 src=up.gif onclick="UpDown(6,1);">
			<input type=text name=5 size=3 maxlength=3 value=0></imput>
			<img border=0 src=down.gif onclick="UpDown(6,0);">
		</td>
		<td><font size=1>Needed to buy defensive structures;<br>Produce aircraft controlled by computer automatically</td>
	<td><font size=1>Residence, Highway, Power Plant/Nuclear Power Plant</td>
	</tr>

	<tr align=center>
	<td><font size=1>Nuclear Plant</td>
	<td><font size=1>500</td>
	<td><font size=1>15</td>
	<td><font size=1>5000</td>
	<td nowrap>
	<img border=0 src=up.gif onclick="UpDown(7,1);">
	<input type=text name=6 size=3 maxlength=3 value=0></imput>
	<img border=0 src=down.gif onclick="UpDown(7,0);">
	</td>
	<td><font size=1>Supplies power for factory and radar station</td>
	<td><font size=1>Residence, Highway</td>
	</tr>

	<tr align=center>
	<td><font size=1>Residence</td>
	<td><font size=1>500</td>
	<td><font size=1>4</td>
	<td><font size=1>1500</td>
	<td nowrap>
	<img border=0 src=up.gif onclick="UpDown(8,1);">
	<input type=text name=7 size=3 maxlength=3 value=0></imput>
	<img border=0 src=down.gif onclick="UpDown(8,0);">
	</td>
	<td><font size=1>Supplies workers for factory, oil refinery and (nuclear) power plant</td>
	<td><font size=1></td>
	</tr>
					

	<tr align=center>
	<td><font size=1>Power Plant</td>
	<td><font size=1>700</td>
	<td><font size=1>12</td>
	<td><font size=1>1000</td>
	<td nowrap>
	<img border=0 src=up.gif onclick="UpDown(9,1);">
	<input type=text name=8 size=3 maxlength=3 value=0></imput>
	<img border=0 src=down.gif onclick="UpDown(9,0);">
	</td>
	<td><font size=1>Supplies power for factory and radar station</td>
	<td><font size=1>Residence, Oil Refinery, Highway</td>
	</tr>
					

	<tr align=center>
	<td><font size=1>Oil Refinery</td>
	<td><font size=1>700</td>
	<td><font size=1>8</td>
	<td><font size=1>1000</td>
	<td nowrap>
	<img border=0 src=up.gif onclick="UpDown(10,1);">
	<input type=text name=9 size=3 maxlength=3 value=0></imput>
	<img border=0 src=down.gif onclick="UpDown(10,0);">
	</td>
	<td><font size=1>Produces fuel for power plant, enables cheaper fuel</td>
	<td><font size=1>Residence, Highway</td>
	</tr>

	</p>

	</body></html>
	</form>



What i'm trying to do, is imput the data from the form into the database.

Basicly the user filles in the text fields with the numbers he wants. So, he presses 5 in the Command center text field, and 5 in Runways. Then he presses the "Construct" button.

After he pressed Construct, it would imput 5 into CC1, 0 into GB1, 0 into Radar1, and so on.



Any advice please?


<input style="font-size:8pt;" type=submit name=cons value=Construct onclick="Go(1,this.form);">



This is the Construct button. Is there anyway I can hook the PHP up to this, so that it inserts the values from the text fields When the user presses this button?

This post has been edited by shygirl15: 22 November 2008 - 09:15 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Trying to get a Form to work

#2 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 543
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 09:57 AM

What's the problem you're getting? If I know what it's doing wrong, it'll be easier to find where it's not correct.

Looking at it as it is now, I can already say that the Javascript on the submit button won't be necessary.
Was This Post Helpful? 0
  • +
  • -

#3 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3103
  • View blog
  • Posts: 10,898
  • Joined: 08-August 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 10:13 AM

View Postshygirl15, on 22 Nov, 2008 - 08:14 AM, said:

Any advice please?

No time to look at your code right now, but here's some general advice:

I try to write code in two files. One is to test the part I'm writing, and the other is the code that's been tested and will eventually be the final product. This way I can build the file up with parts that I know work. It's not fool proof, but it helps.
Was This Post Helpful? 0
  • +
  • -

#4 shygirl15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 21-November 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 10:46 AM

<form name="nala" action="construct.php" method="post">


<input style="font-size:8pt;" type=submit name=cons value=Construct> 
 / 
 <input style="font-size:8pt;" type=submit name=dest value=Destroy> buildings to highlighted sector




<table border=1 bordercolor=#003399 cellspacing=0 width=95%>
	<tr align=center bgcolor=#003399>
		<td><font size=1>Name</td>
		<td><font size=1>Hit<br>Point</td>
		<td><font size=1>Armor</td>
		<td><font size=1>Price<td wrap=><font size=1>Amount</td>
		<td><font size=1>Description</td>
		<td><font size=1>Dependency</td>
	</tr>
			
<input type=hidden name="npc[]" value=1>
<tr align=center>
	<td><font size=1>Command Center</td>
	<td><font size=1>2200</td>
	<td><font size=1>25</td>
	<td><font size=1>10000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(2,1);">




		<input name="amount1" type=text size=3 maxlength=3 value=0>






		<img border=0 src=down.gif onclick="UpDown(2,0);">
	</td>
	<td><font size=1>Defensive structures and aircraft controlled by computer can attack enemy</td>
	<td><font size=1> </td>
</tr>









					
<input type=hidden name="npc[]" value=2>
<tr align=center>
	<td><font size=1>Government Bldg.</td>
	<td><font size=1>1500</td>
	<td><font size=1>20</td>
	<td><font size=1>9000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(3,1);">


<input name="amount2" type=text size=3 maxlength=3 value=0>




		<img border=0 src=down.gif onclick="UpDown(3,0);">
	</td>
	<td><font size=1>Collect tax from residence, 100 credits per residence</td>
	<td><font size=1> </td>
</tr>







					
<input type=hidden name="npc[]" value=3>
<tr align=center>
	<td><font size=1>Radar Station</td>
	<td><font size=1>500</td>
	<td><font size=1>25</td>
	<td><font size=1>3000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(4,1);">
		<input name="amount3" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(4,0);">
	</td>
	<td><font size=1>Your wing radar while in base</td>
	<td><font size=1>Power Plant/Nuclear Power Plant</td>
</tr>
					
<input type=hidden name="npc[]" value=4>
<tr align=center>
	<td><font size=1>Runway</td>
	<td><font size=1>350</td>
	<td><font size=1>5</td>
	<td><font size=1>1000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(5,1);">
		<input name="amount4" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(5,0);">
	</td>
	<td><font size=1>Needed for your aircraft to take off</td>
	<td><font size=1></td>
</tr>
					
<input type=hidden name="npc[]" value=5>
<tr align=center>
	<td><font size=1>Factory</td>
	<td><font size=1>800</td>
	<td><font size=1>10</td>
	<td><font size=1>1000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(6,1);">
		<input name="amount5" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(6,0);">
	</td>
	<td><font size=1>Needed to buy defensive structures;<br>Produce aircraft controlled by computer automatically</td>
	<td><font size=1>Residence, Highway, Power Plant/Nuclear Power Plant</td>
</tr>
					
<input type=hidden name="npc[]" value=6>
<tr align=center>
	<td><font size=1>Nuclear Plant</td>
	<td><font size=1>500</td>
	<td><font size=1>15</td>
	<td><font size=1>5000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(7,1);">
		<input name="amount6" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(7,0);">
	</td>
	<td><font size=1>Supplies power for factory and radar station</td>
	<td><font size=1>Residence, Highway</td>
</tr>
					
<input type=hidden name="npc[]" value=7>
<tr align=center>
	<td><font size=1>Residence</td>
	<td><font size=1>500</td>
	<td><font size=1>4</td>
	<td><font size=1>1500</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(8,1);">
		<input name="amount7" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(8,0);">
	</td>
	<td><font size=1>Supplies workers for factory, oil refinery and (nuclear) power plant</td>
	<td><font size=1></td>
</tr>
					
<input type=hidden name="npc[]" value=8>
<tr align=center>
	<td><font size=1>Power Plant</td>
	<td><font size=1>700</td>
	<td><font size=1>12</td>
	<td><font size=1>1000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(9,1);">
		<input name="amount8" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(9,0);">
	</td>
	<td><font size=1>Supplies power for factory and radar station</td>
	<td><font size=1>Residence, Oil Refinery, Highway</td>
</tr>
					
<input type=hidden name="npc[]" value=9>
<tr align=center>
	<td><font size=1>Oil Refinery</td>
	<td><font size=1>700</td>
	<td><font size=1>8</td>
	<td><font size=1>1000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(10,1);">
		<input name="amount9" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(10,0);">
	</td>
	<td><font size=1>Produces fuel for power plant, enables cheaper fuel</td>
	<td><font size=1>Residence, Highway</td>
</tr>


</form>




This Is the form.











<?php
$username="151296";
$password="puppypuppy";
$database="151296";
mysql_connect($localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$last = $_COOKIE['ID_my_site']; 

$query = "SELECT * FROM wings, users where wings.Numero = users.Wing AND users.username = '" . $last ."'";
$query2 = "SELECT Wing From users where users.Wing = 0";
$result = mysql_query($query);
$result2 = mysql_query($query2);


	$sql = "INSERT INTO wings (CC1, GB1, Radar1, Runway1, Factory1, NP1, Residence1, PP1, Oil1) 
				VALUES (".(int)$_POST[amout1].",".(int)$_POST[amount2].",".(int)$_POST[amount3].",".(int)$_POST[amount4].",".(int)$_POST[amount5].",".(int)$_POST[amount6].",".(int)$_POST[amount7].",".(int)$_POST[amount8].",".(int)$_POST[amount9].");";  
}
$result = mysql_query($sql)or die ("Error. Could not do SQL query!");
?>



This is construct.php














When I enter the data into the text fields, and press Construct. It goes to the form, but none of the data is imputed, and I get a grey screen.

Can someone please point out why I would be getting a grey screen?
Was This Post Helpful? 0
  • +
  • -

#5 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 543
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 11:23 AM

Try replacing this:

    $sql = "INSERT INTO wings (CC1, GB1, Radar1, Runway1, Factory1, NP1, Residence1, PP1, Oil1)
                VALUES (".(int)$_POST[amout1].",".(int)$_POST[amount2].",".(int)$_POST[amount3].",".(int)$_POST[amount4].",".(int)$_POST[amount5].",".(int)$_POST[amount6].",".(int)$_POST[amount7].",".(int)$_POST[amount8].",".(int)$_POST[amount9].");";  


With this:

    $sql = "INSERT INTO wings ('CC1', 'GB1', 'Radar1', 'Runway1', 'Factory1', 'NP1', 'Residence1', 'PP1', 'Oil1')
                VALUES ('".$_POST['amount1']."','".$_POST['amount2']."','".$_POST['amount3']."','".$_POST['amount4']."','".$_POST['amount5']."','".$_POST['amount6']."','".$_POST['amount7']."','".$_POST['amount8']."','".$_POST['amount9']."');";  


Just a quick guess just by looking at the query.

This post has been edited by Valek: 22 November 2008 - 11:24 AM

Was This Post Helpful? 0
  • +
  • -

#6 shygirl15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 21-November 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 11:38 AM

<?php
ini_set('display_errors','On');

$username="151296";
$password="puppypuppy";
$database="151296";
mysql_connect($localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$last = $_COOKIE['ID_my_site']; 

$query = "SELECT * FROM wings, users where wings.Numero = users.Wing AND users.username = '" . $last ."'";
$query2 = "SELECT Wing From users where users.Wing = 0";
$result = mysql_query($query);
$result2 = mysql_query($query2);


	$sql = "INSERT INTO wings (CC1, GB1, Radar1, Runway1, Factory1, NP1, Residence1, PP1, Oil1) 
				VALUES ($_POST[amout1], $_POST[amount2], $_POST[amount3], $_POST[amount4], $_POST[amount5], $_POST[amount6], $_POST[amount7], $_POST[amount8], $_POST[amount9]);";  
}
$result = mysql_query($sql)or die ("Error. Could not do SQL query!");
?>




Still grey screen.
Was This Post Helpful? 0
  • +
  • -

#7 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 543
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 11:40 AM

The grey screen is because construct.php doesn't do anything beyond submitting a DB query.
Was This Post Helpful? 0
  • +
  • -

#8 shygirl15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 21-November 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 11:53 AM

View PostValek, on 22 Nov, 2008 - 10:40 AM, said:

The grey screen is because construct.php doesn't do anything beyond submitting a DB query.


The problem is that it isn't being imput into the database either.

Do me a favor and go to http://planez.orgfree.com

login with username: energy and password: puppy

click "Arming", and then type a number in, and press Construct. Now go back to Arming. Notice none of the numbers being echo'd from the database has changed?


P.S. this site only works for IE I think.
Was This Post Helpful? 0
  • +
  • -

#9 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 543
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 12:01 PM

View Postshygirl15, on 22 Nov, 2008 - 01:53 PM, said:

The problem is that it isn't being imput into the database either.

Do me a favor and go to http://planez.orgfree.com

login with username: energy and password: puppy

click "Arming", and then type a number in, and press Construct. Now go back to Arming. Notice none of the numbers being echo'd from the database has changed?


That's why I gave you the modified query, in an attempt to troubleshoot that. You had a typo in there anyway.

View Postshygirl15, on 22 Nov, 2008 - 01:53 PM, said:

P.S. this site only works for IE I think.


Yeap. You might want to fix that or implement browser detection.
Was This Post Helpful? 0
  • +
  • -

#10 shygirl15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 21-November 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 12:26 PM

I put your code in. It still just goes to a white/grey screen, and fails to imput anything into the database.

If you see no problem with the code, then maybe its the form itself that is causing the problem? Would you like to see it? It's kinda long.
Was This Post Helpful? 0
  • +
  • -

#11 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 543
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 12:33 PM

The grey screen is because construct.php doesn't actually dispaly anything, it just runs the database code. You could put header("Location: form.php"); if you want it to return to the form after it does all of that. Unless you have it generate output or use a header() redirect, it's going to be a blank screen.

Also, with the query, maybe this instead:

$sql = sprintf("INSERT INTO wings ('CC1', 'GB1', 'Radar1', 'Runway1', 'Factory1', 'NP1', 'Residence1', 'PP1', 'Oil1') VALUES ('$_POST['amount1']','$_POST['amount2']','$_POST['amount3']','$_POST['amount4']','$_POST['amount5']','$_POST['amount6']','$_POST['amount7']','$_POST['amount8']','$_POST['amount9']');";

Was This Post Helpful? 0
  • +
  • -

#12 shygirl15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 21-November 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 12:42 PM

Hey Valek. Thank you for your fast responses. It means alot ot me. I have been working all night to try and get this to work, so I really do appreciate your help.

<?php
ini_set('display_errors','On');

$username="151296";
$password="puppypuppy";
$database="151296";
mysql_connect($localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$last = $_COOKIE['ID_my_site']; 

$query = "SELECT * FROM wings, users where wings.Numero = users.Wing AND users.username = '" . $last ."'";
$query2 = "SELECT Wing From users where users.Wing = 0";
$result = mysql_query($query);
$result2 = mysql_query($query2);

$sql = sprintf("INSERT INTO wings ('CC1', 'GB1', 'Radar1', 'Runway1', 'Factory1', 'NP1', 'Residence1', 'PP1', 'Oil1') VALUES ('$_POST['amount1']','$_POST['amount2']','$_POST['amount3']','$_POST['amount4']','$_POST['amount5']','$_POST['amount6']','$_POST['amount7']','$_POST['amount8']','$_POST['amount9']');"; 





   
}
$result = mysql_query($sql)or die ("Error. Could not do SQL query!");

header("Location: arming.php");
?>






This is what I have now. Still getting white screen. I put in the header thing like you said. Also, I changed the query to no avail. Database still isnt being updated.

Does this site allow for me to ask your MSN?
Was This Post Helpful? 0
  • +
  • -

#13 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 543
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 12:48 PM

Well, you apparently removed this part, it seems:

}
$result = mysql_query($sql)or die ("Error. Could not do SQL query!");
?>


I would recommend adding that back, but as this:

$result = mysql_query($sql)or die ("Error. Could not do SQL query!");
header("Location: form.php");
?>


You had a closing bracket without it closing anything.

You probably also have error reporting off for some reason. Switch ini_set('display_errors','On'); to error_reporting(E_ALL); and see how that does. Or update it directly in php.ini.

This post has been edited by Valek: 22 November 2008 - 12:49 PM

Was This Post Helpful? 1
  • +
  • -

#14 shygirl15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 21-November 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 12:56 PM

<?php

error_reporting(E_ALL);

$username="151296";
$password="puppypuppy";
$database="151296";
mysql_connect($localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$last = $_COOKIE['ID_my_site']; 

$query = "SELECT * FROM wings, users where wings.Numero = users.Wing AND users.username = '" . $last ."'";
$query2 = "SELECT Wing From users where users.Wing = 0";
$result = mysql_query($query);
$result2 = mysql_query($query2);

$sql = sprintf("INSERT INTO wings ('CC1', 'GB1', 'Radar1', 'Runway1', 'Factory1', 'NP1', 'Residence1', 'PP1', 'Oil1') VALUES ('$_POST['amount1']','$_POST['amount2']','$_POST['amount3']','$_POST['amount4']','$_POST['amount5']','$_POST['amount6']','$_POST['amount7']','$_POST['amount8']','$_POST['amount9']');"; 





   

$result = mysql_query($sql)or die ("Error. Could not do SQL query!");

header("Location: arming.php");
?>









Changed what you said.



I can not figure out what could stop the data from imputing. I'm going to show you the code of the form. Maybe this is the problem.




<form name="nala" action="construct.php" method="post">


<input style="font-size:8pt;" type=submit name=cons value=Construct> 
 / 
 <input style="font-size:8pt;" type=submit name=dest value=Destroy> buildings to highlighted sector




<table border=1 bordercolor=#003399 cellspacing=0 width=95%>
	<tr align=center bgcolor=#003399>
		<td><font size=1>Name</td>
		<td><font size=1>Hit<br>Point</td>
		<td><font size=1>Armor</td>
		<td><font size=1>Price<td wrap=><font size=1>Amount</td>
		<td><font size=1>Description</td>
		<td><font size=1>Dependency</td>
	</tr>
			
<input type=hidden name="npc[]" value=1>
<tr align=center>
	<td><font size=1>Command Center</td>
	<td><font size=1>2200</td>
	<td><font size=1>25</td>
	<td><font size=1>10000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(2,1);">




		<input name="amount1" type=text size=3 maxlength=3 value=0>






		<img border=0 src=down.gif onclick="UpDown(2,0);">
	</td>
	<td><font size=1>Defensive structures and aircraft controlled by computer can attack enemy</td>
	<td><font size=1> </td>
</tr>









					
<input type=hidden name="npc[]" value=2>
<tr align=center>
	<td><font size=1>Government Bldg.</td>
	<td><font size=1>1500</td>
	<td><font size=1>20</td>
	<td><font size=1>9000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(3,1);">


<input name="amount2" type=text size=3 maxlength=3 value=0>




		<img border=0 src=down.gif onclick="UpDown(3,0);">
	</td>
	<td><font size=1>Collect tax from residence, 100 credits per residence</td>
	<td><font size=1> </td>
</tr>







					
<input type=hidden name="npc[]" value=3>
<tr align=center>
	<td><font size=1>Radar Station</td>
	<td><font size=1>500</td>
	<td><font size=1>25</td>
	<td><font size=1>3000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(4,1);">
		<input name="amount3" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(4,0);">
	</td>
	<td><font size=1>Your wing radar while in base</td>
	<td><font size=1>Power Plant/Nuclear Power Plant</td>
</tr>
					
<input type=hidden name="npc[]" value=4>
<tr align=center>
	<td><font size=1>Runway</td>
	<td><font size=1>350</td>
	<td><font size=1>5</td>
	<td><font size=1>1000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(5,1);">
		<input name="amount4" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(5,0);">
	</td>
	<td><font size=1>Needed for your aircraft to take off</td>
	<td><font size=1></td>
</tr>
					
<input type=hidden name="npc[]" value=5>
<tr align=center>
	<td><font size=1>Factory</td>
	<td><font size=1>800</td>
	<td><font size=1>10</td>
	<td><font size=1>1000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(6,1);">
		<input name="amount5" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(6,0);">
	</td>
	<td><font size=1>Needed to buy defensive structures;<br>Produce aircraft controlled by computer automatically</td>
	<td><font size=1>Residence, Highway, Power Plant/Nuclear Power Plant</td>
</tr>
					
<input type=hidden name="npc[]" value=6>
<tr align=center>
	<td><font size=1>Nuclear Plant</td>
	<td><font size=1>500</td>
	<td><font size=1>15</td>
	<td><font size=1>5000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(7,1);">
		<input name="amount6" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(7,0);">
	</td>
	<td><font size=1>Supplies power for factory and radar station</td>
	<td><font size=1>Residence, Highway</td>
</tr>
					
<input type=hidden name="npc[]" value=7>
<tr align=center>
	<td><font size=1>Residence</td>
	<td><font size=1>500</td>
	<td><font size=1>4</td>
	<td><font size=1>1500</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(8,1);">
		<input name="amount7" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(8,0);">
	</td>
	<td><font size=1>Supplies workers for factory, oil refinery and (nuclear) power plant</td>
	<td><font size=1></td>
</tr>
					
<input type=hidden name="npc[]" value=8>
<tr align=center>
	<td><font size=1>Power Plant</td>
	<td><font size=1>700</td>
	<td><font size=1>12</td>
	<td><font size=1>1000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(9,1);">
		<input name="amount8" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(9,0);">
	</td>
	<td><font size=1>Supplies power for factory and radar station</td>
	<td><font size=1>Residence, Oil Refinery, Highway</td>
</tr>
					
<input type=hidden name="npc[]" value=9>
<tr align=center>
	<td><font size=1>Oil Refinery</td>
	<td><font size=1>700</td>
	<td><font size=1>8</td>
	<td><font size=1>1000</td>
	<td nowrap>
		<img border=0 src=up.gif onclick="UpDown(10,1);">
		<input name="amount9" type=text size=3 maxlength=3 value=0>
		<img border=0 src=down.gif onclick="UpDown(10,0);">
	</td>
	<td><font size=1>Produces fuel for power plant, enables cheaper fuel</td>
	<td><font size=1>Residence, Highway</td>
</tr>


</form>




Do you see anything that would stop the imput of data when I click the "Construct" button?
Was This Post Helpful? 0
  • +
  • -

#15 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 543
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Trying to get a Form to work

Posted 22 November 2008 - 01:04 PM

Okay, let's double-check the query then.

Comment out the $result line that does the query. Replace it with a line that echoes $sql, so we can look at the query and be sure that the data is arriving there appropriately.

Also, out of curiosity, why are those other two queries in construct.php? I don't see them being used for anything in there.

This post has been edited by Valek: 22 November 2008 - 01:05 PM

Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3