Jump to content

[resolved] my form doesnt work :(


raymens

Recommended Posts

Hello everyone, i got a aproblem with my form, if i fill/update in the form and press on the submit button. it doesnt update my form :( it just reload the page with the form.
this is the page:
[code]<?php

require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";

require_once ("config.php");
require_once ("maincore.php");

    if (isset($_POST['Wijzig])) {
$update_date = date("d-m-Y H:i");
$sql = "UPDATE projects (name, description, update_date, progress)
                      VALUES('" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($update_date) . "', '" . mysql_real_escape_string($_POST['progress']) . "');
$res = mysql_query($sql) or die(mysql_error());
echo $res;
echo " Project succesvol gewijzigd";
} else{

$id = $_GET['id'];
$username = $userdata['user_name'];

$sql = "SELECT id,name,description,author,date FROM projects WHERE id = '$id'";
$res = mysql_query($sql);
$num = mysql_num_rows($res);
$d = mysql_fetch_array($res);
   
if ($username == $d['author']) {
echo "<h3>Wijzig uw Project:</h3>";
    ?>  
<table border="0"><form method="post" action="addproject.php?id="<?php echo $d['id']; ?>" enctype="multipart/form-data">
<tr><td width="40%">Project Naam:</td><td><input type="text" size="20" maxlength="20" name="name" value="<? echo $d['name']; ?> ">(Max 20 chars)</td></tr>
<tr><td width="40%">Project Beschrijving:</td><td><textarea name="description" rows="8" cols="31"><?php echo $d['description']; ?></textarea></td></tr>
<tr><td width="40%">Percentage klaar:</td><td><select><option name="0">0</option> <option name="10">10</option> <option name="20">20</option> <option name="30">30</option><option name="40">40</option> <option name="50">50</option><option name="60">60</option> <option name="70">70</option><option name="80">80</option> <option name="90">90</option><option name="100">100</option></select> </td></tr>
<tr><td width="40%"></td><td><input type="Submit" name="Wijzig" value="Wijzig">
</table></form>
<?
}
else{
echo "U heeft niet het recht om dit project te wijzigen";
}
}

require_once "side_right.php";
require_once "footer.php";
?>[/code]
Link to comment
Share on other sites

ok, i changed that but my error now is: Parse error: parse error, unexpected T_STRING in C:\Program Files\xampp\htdocs\php-fusion\update_project.php on line 16

This is my script now:
[code]<?php
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";

require_once ("config.php");
require_once ("maincore.php");

    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    //$id = $_GET['id'];
$update_date = date("d-m-Y H:i");
$sql = "UPDATE projects set (name, description, update_date, progress) WHERE id = '$id'
                      VALUES('" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($update_date) . "', '" . mysql_real_escape_string($_POST['progress']) . "');
$res = mysql_query($sql) or die(mysql_error());
echo $res;
echo " Project succesvol gewijzigd";
} else{

$id = $_GET['id'];
$username = $userdata['user_name'];

$sql = "SELECT id,name,description,author,date FROM projects WHERE id = '$id'";
$res = mysql_query($sql);
$num = mysql_num_rows($res);
$d = mysql_fetch_array($res);
   
if ($username == $d['author']) {
echo "<h3>Wijzig uw Project:</h3>";
    ?>  
<table border="0"><form method="post" action="addproject.php?id="<?php echo $d['id']; ?>" enctype="multipart/form-data">
<tr><td width="40%">Project Naam:</td><td><input type="text" size="20" maxlength="20" name="name" value="<? echo $d['name']; ?> ">(Max 20 chars)</td></tr>
<tr><td width="40%">Project Beschrijving:</td><td><textarea name="description" rows="8" cols="31"><?php echo $d['description']; ?></textarea></td></tr>
<tr><td width="40%">Percentage klaar:</td><td><select><option name="0">0</option> <option name="10">10</option> <option name="20">20</option> <option name="30">30</option><option name="40">40</option> <option name="50">50</option><option name="60">60</option> <option name="70">70</option><option name="80">80</option> <option name="90">90</option><option name="100">100</option></select> </td></tr>
<tr><td width="40%"></td><td><input type="Submit" name="Wijzig" value="Wijzig">
</table></form>
<?
}
else{
echo "U heeft niet het recht om dit project te wijzigen";
}
}

require_once "side_right.php";
require_once "footer.php";
?>[/code]
Link to comment
Share on other sites

You have misplaced the WHERE stuff
[code]
<?php

$sql = "UPDATE projects set (name, description, update_date, progress) VALUES ('" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($update_date) . "', '" . mysql_real_escape_string($_POST['progress']) . "' WHERE id = '$id'");

?>
[/code]
Link to comment
Share on other sites

i get this error now:
Parse error: parse error, unexpected T_STRING in C:\Program Files\xampp\htdocs\php-fusion\update_project.php on line 17

[code]<?php
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";

require_once ("config.php");
require_once ("maincore.php");

    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $id = $_GET['id'];
$update_date = date("d-m-Y H:i");
$sql = "UPDATE projects set (name, description, update_date, progress)
VALUES ('" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($update_date) . "', '" . mysql_real_escape_string($_POST['progress']) . "' WHERE id = '$id');

$res = mysql_query($sql) or die(mysql_error());
echo $res;
echo " Project succesvol gewijzigd";
} else{

$id = $_GET['id'];
$username = $userdata['user_name'];

$sql = "SELECT id,name,description,author,date FROM projects WHERE id = '$id'";
$res = mysql_query($sql);
$num = mysql_num_rows($res);
$d = mysql_fetch_array($res);
   
if ($username == $d['author']) {
echo "<h3>Wijzig uw Project:</h3>";
    ?>  
<table border="0"><form method="post" action="addproject.php?id="<?php echo $d['id']; ?>" enctype="multipart/form-data">
<tr><td width="40%">Project Naam:</td><td><input type="text" size="20" maxlength="20" name="name" value="<? echo $d['name']; ?> ">(Max 20 chars)</td></tr>
<tr><td width="40%">Project Beschrijving:</td><td><textarea name="description" rows="8" cols="31"><?php echo $d['description']; ?></textarea></td></tr>
<tr><td width="40%">Percentage klaar:</td><td><select><option name="0">0</option> <option name="10">10</option> <option name="20">20</option> <option name="30">30</option><option name="40">40</option> <option name="50">50</option><option name="60">60</option> <option name="70">70</option><option name="80">80</option> <option name="90">90</option><option name="100">100</option></select> </td></tr>
<tr><td width="40%"></td><td><input type="Submit" name="Wijzig" value="Wijzig">
</table></form>
<?
}
else{
echo "U heeft niet het recht om dit project te wijzigen";
}
}

require_once "side_right.php";
require_once "footer.php";
?>[/code]
Link to comment
Share on other sites

OK, i had a typo in my last code BUT you also left out a quote, now - try this out:
[code]

<?php

require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";
require_once "config.php";
require_once "maincore.php";

if (isset($_POST["Wijzig"]))
{
$id = $_POST['id'];
settype($id,"integer");
$update_date = date("d-m-Y H:i");
$name = mysql_real_escape_string($_POST['name']);
$descr = mysql_real_escape_string($_POST['description']);
$progress = mysql_real_escape_string($_POST['progress']);

$sql = "UPDATE projects set (name, description, update_date, progress) VALUES ('$name', '$descr', '$update_date', '$progress' WHERE id = '$id'";
$res = mysql_query($sql) or die(mysql_error());
echo $res;
echo " Project succesvol gewijzigd";
}
else
{
$id = $_GET['id'];
$username = $userdata['user_name'];

$sql = "SELECT id,name,description,author,date FROM projects WHERE id = '$id'";
$res = mysql_query($sql);
$num = mysql_num_rows($res);
$d = mysql_fetch_array($res);

if ($username == $d['author'])
{
echo <<<_HTML

<h3>Wijzig uw Project:</h3>
<form method="post" action="addproject.php" enctype="multipart/form-data">
<table border="0">
<tr>
<td width="40%">Project Naam:</td>
<td>
<input type="hidden" name="id" value="{$d['id']}">
<input type="text" size="20" maxlength="20" name="name" value="{$d['name']}">(Max 20 chars)
</td>
</tr><tr>
<td width="40%">Project Beschrijving:</td>
<td><textarea name="description" rows="8" cols="31">{$d['description']}</textarea></td>
</tr><tr>
<td width="40%">Percentage klaar:</td>
<td>
<select name="progress">
<option value="0">0</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
<option value="60">60</option>
<option value="70">70</option>
<option value="80">80</option>
<option value="90">90</option>
<option value="100">100</option>
</select>
</td>
</tr><tr>
<td width="40%"></td>
<td><input type="Submit" name="Wijzig" value="Wijzig"></td>
</tr>
</table>
</form>

_HTML;
}
else
{
echo "U heeft niet het recht om dit project te wijzigen";
}
}

require_once 'side_right.php';
require_once 'footer.php';

?>

[/code]
Link to comment
Share on other sites

if i click on submit(wijzig) now, this error appears:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(name, description, update_date, progress) VALUES ('Infusion: Project', 'Een Inf' at line 1
Link to comment
Share on other sites


Change this update query
[code]
$sql = "UPDATE projects set (name, description, update_date, progress) VALUES ('$name', '$descr', '$update_date', '$progress' WHERE id = '$id'";

[/code]

Like this,

[code]
$sql= "UPDATE projects set name='$name',description='$descr',updte_date='$update_date',progress='$progress' where id= '$id' ";
[/code]

Cheers!
Link to comment
Share on other sites


Make sure that all variables are passing to that query or not! pritn the query to the browser.

[code]
$sql= "UPDATE projects set name='$name',description='$descr',updte_date='$update_date',progress='$progress' where id= '$id' ";
echo $sql;
[/code]

If all variables are passing correctly, then check the query directly in phpMyAdmin.

Regards,
Joshi.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.