logo-dw

Go Back   Dreamweaver Club Forums > Dreamweaver forums > Video Tutorials
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 11-18-2007, 08:40 PM   #1
-fedexer-
 
Join Date: Aug 2007
Posts: 58
Default PHP, a beginners guide, part 9.

I have followed the tutorial completely through, but when i hit submit, instead of returning to itself the page seems to go to the main directory, whilst displaying a 404 error. Im sure i have done everything correctly, and i have checked it and i cant seem to find anything wrong, could someone take a look and see if i have overlooked something.

Code:
<?php
require_once("Connections/connection.php"); //database connection

////////////////////////////////////////////////////
$data2   = $_POST['data2'];
$data3   = $_POST['data3'];
$data4   = $_POST['data4'];
$submit   = $_POST['submit'];
//////////////////////////////////////////////////

if($submit && $data2 && $data3 && data4) {   
 //checking that the table has been populated (data entered) when submit is pressed
////////////////////////////////////
$query = sprintf("INSERT into table1 (field2, field3, field4) values ('$data2', '$data3', '$data4')");
   mysql_query($query)or die(mysql_error());
////////////////////////////////////
}elseif($submit) {
echo "One of your fields is empty!";
}
//////////////////////////////////////////////
$query  = sprintf("SELECT * FROM table1");
$result  = @mysql_query($query);
$row  = mysql_fetch_array($result);
////////////////////////////////////////////////
?>

<!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=utf-8" />
<title>dwc.php</title>
<style type="text/css">
<!--
.style1 {font-size: 24px}
#apDiv1 {
 position:absolute;
 left:357px;
 top:217px;
 width:355px;
 height:107px;
 z-index:1;
}
#apDiv2 {
 position:absolute;
 left:240px;
 top:56px;
 width:907px;
 height:98px;
 z-index:2;
}
#apDiv3 {
 position:absolute;
 left:388px;
 top:60px;
 width:497px;
 height:118px;
 z-index:2;
}
-->
</style>
</head>
<body>
<div id="apDiv1">
  <table width="569" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>ID</td>
      <td>Data2</td>
      <td>Data3</td>
      <td>Data4</td>
    </tr>
    <?php do{ ?>
    <tr>
      <td><?php echo $row['field1_id'];?></td>
      <td><?php echo $row['field2'];?></td>
      <td><?php echo $row['field3'];?></td>
      <td><?php echo $row['field4'];?></td>
    </tr>
    <?php }while ($row = mysql_fetch_array($result)) ?>
  </table>
</div>
<form id="form1" name="form1" method="post" action=" <?php $_SERVER['PHP_SELF']; ?> ">
  <table width="389" border="1" cellpadding="0" cellspacing="0" id="apDiv2">
    <tr>
      <td width="145">data2</td>
      <td width="122">data3</td>
      <td width="114">data4</td>
    </tr>
    <tr>
      <td height="25"><label>
        <input type="text" name="data2" id="data2" />
      </label></td>
      <td><label>
        <input type="text" name="data3" id="data3" />
      </label></td>
      <td><label>
        <input type="text" name="data4" id="data4" />
      </label></td>
    </tr>
    <tr>
      <td colspan="3"><label>
        <div align="center">
          <input type="submit" name="Submit" id="Submit" value="Submit" />
          <input name="submit" type="hidden" id="submit" value="1" />
        </div>
      </label></td>
    </tr>
    </table>
</form>
</body>
</html>
Thanks
-fedexer-
-fedexer- is offline   Reply With Quote
Old 11-18-2007, 09:11 PM   #2
-fedexer-
 
Join Date: Aug 2007
Posts: 58
Default

Note: this works in FF but not any other browsers. (dont know why)
-fedexer- is offline   Reply With Quote
Old 11-19-2007, 07:42 AM   #3
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

try replacing...

PHP Code:
<?php $_SERVER['PHP_SELF']; ?>
with the page name

PHP Code:
my_page.php 
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 11-19-2007, 02:45 PM   #4
-fedexer-
 
Join Date: Aug 2007
Posts: 58
Default

Intrequing, that fixed my problem david

Only problem that still resides , is that if i try to view the page using Yahoo Browser (my default browser) it asks me if i want :

Code:
Warning: the web page which you are about to visit may attempt to request your personal information (such as passwords, credit card numbers and social security numbers) for unauthorized use or may otherwise attempt to harm your computer.
Malicious web sites can use this type of address in order to disguise themselves.   The destination may appear to be:
 %22http
but the actual destination is:
 %22http
i click yes to continue, but then my browser just closes.... is this because im viewing it on my machine and it would work on the net?

or is it something else that is possibly causing this problem

(i want to make sure all browsers are compatable)

Thanks

-fedexer-
-fedexer- is offline   Reply With Quote
Old 11-19-2007, 02:59 PM   #5
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

try the site in IE or fire fox
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 11-19-2007, 03:01 PM   #6
-fedexer-
 
Join Date: Aug 2007
Posts: 58
Default

works fine in IE and FF , just not yahoo Browser for some reason, it throws that warning message as it attempts to open it , then you click yes, it looks like its loading and then it just closes.
-fedexer- is offline   Reply With Quote
Old 11-19-2007, 03:03 PM   #7
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

sounds like a dodgy install

or the security settings are too strict

use a proper browser like FF
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 11-19-2007, 03:04 PM   #8
-fedexer-
 
Join Date: Aug 2007
Posts: 58
Default

haha sure thing ill just use FF / IE for testing, (i have IE set as default for testing anyway)

Thanks alot david

Now i can get on with the other VTMs after i finish my homework

-fedexer-
-fedexer- is offline   Reply With Quote
Reply


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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:17 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com