FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

make a backoffice

 


Reyntjensw
hi,

i want to make a backoffice system, can someone tell me how i can update my mysql database true a php script?


grtz
Code:
<?php



if ($submit) {

  // process form

  $db = mysql_connect("localhost", "username", "psword");

  mysql_select_db("dbname",$db);

  $sql = "UPDATE vragenlijst SET voornaam = '$voornaam'";

  $result = mysql_query($sql);

  echo "Bedankt voor de gegevens in te vullen, klik op index om terug naar de hoofdpagina te gaan.\n";

} else{



  // display form



  ?>


<table>

<tr>
  <form method="post" action="<?php $_POST['voornaam']"?>

  <td class="style1">Voornaam:</td><td><input type="Text" name="voornaam"><br></td></tr>
     
 </table>



  <input type="Submit" name="submit" value="Verzend">

  </form>



  <?php



} // end if



?>


whats wrong with this script?
simplyw00x
This assumes register_globals is on. IMO it's not. You need to set the variables manually. Like so:
Code:
  // process form

  $db = mysql_connect("localhost", "username", "psword");

  mysql_select_db("dbname",$db);

  $voornaam = $_POST['voornaam'];

  $sql = "UPDATE vragenlijst SET voornaam = '$voornaam'";

  $result = mysql_query($sql);
Reyntjensw
Is this correct?
Code:
<?php
if ($submit) {


  // process form

  $db = mysql_connect("localhost", "dbuser", "pasword");

  mysql_select_db("db",$db);

  $voornaam = $_POST['voornaam'];

  $sql = "UPDATE vragenlijst SET voornaam = '$voornaam'";

  $result = mysql_query($sql);


  // display form


  ?>


<table>

<tr>
  <form method="post" action="<?php $_POST['voornaam']"?>

  <td class="style1">Voornaam:</td><td><input type="Text" name="voornaam"><br></td></tr>
     
 </table>



  <input type="Submit" name="submit" value="Verzend">

  </form>



  <?php



} // end if



?>


this is the link http://chismoor.ahplace.com/test2.php
mathiaus
This lines messed up
<form method="post" action="<?php $_POST['voornaam']"?>


Don't know what your trying to do with the action but either leave it blank
<form method="post" action="">
or move the quote
<form method="post" action="<?php $_POST['voornaam']; ?>">
Reyntjensw
i've changed it but it still doesn't work!
for an example click on the previous link


grtz
mathiaus
I should've checked the whole code sorry. You have told it to only show the form when its submitted (impossible) Rolling Eyes

This way will show the form all the time
http://frihost.pastebin.com/749924

And this way only when it isnt submitted
http://frihost.pastebin.com/749923
Reyntjensw
thanks mathiaus, it's just what i needed!
i've got just 2 more questions:

1) i've got a script that displays whats in the database, is it possible to do the folowing things:

* i've changed the input field into a textarea can i display the content of the database (so whats in it) when i go to the page you gave me? if yes, how?

* if you click on submit, can you display whats in it with the script i posted below?

Code:

<?php
// Make a MySQL Connection
mysql_connect("localhost", "user", "pasword") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());

// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM vragenlijst ORDER BY voornaam")
or die(mysql_error());



echo "<table border='1'>";
echo "<tr> <th>Voornaam</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['voornaam'];
}
echo "</table>";

?>


thanks a lot
Related topics
Can someone make me a php script?
Make a mIRC channel
Make search engine With PHP and mySQL, for your site
22 Lines to Make You Smile
Tieskevo's HOW TO MAKE AN REAL NICE LAYOUT TUTORIAL
Is it possible to make Mambo CMS searchable in Google?
Easiest way to make frontpage?
Make Firefox Faster
can someone please make me a picture sig?
how to make a SITE on ftp not a forum
How to make a symlink
Korean man 'overdoses' on gaming
How To Make A Mini-Image for safedisc 4
how to make brushes:
Does this subject make any sense?
Resident Evil 4 can a 11 or 12 yearold play
have you ever tried to make a game??
Make an official free game thread
How to Make Good Posts
make up a Suspended list
Please show me how to make 3D graphics in Photoshop 7.0.
Free Online Games (Do not make more new threads about this)
Can anyone make a script like top 100/200 sites/servers?
Posting Guidelines / Guidelines to Make Quality Posts
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.