I am trying to write a little project management webapps as a newby – I do appologise for this but I could not find any near…
So I have x type of project which can be select and load through AJAX.
Every type has at least 2-3 steps to complete them so I need more php pages.
I have spent lots of time to figure it out but it is time to ask someone who knows the answer.
Question: When User presses the Submit button I need to check if all the input box are correct and then save to a SQL table and then move to the next page if any of these would fail I have to stop.
code:
<form id="pdf" method="post">
New project name:<input type="text" name="pr-name" placeholder="new project name..."><br/>
New project end date:<input type="text" name="pr-end" placeholder="date..."><br/>
<textarea class="ckeditor" name="pagecontent" id="pagecontent"></textarea>
<?php
include_once "ckeditor/ckeditor.php";
$CKEditor = new CKEditor();
$CKEditor->basePath = 'ckeditor/';
// Set global configuration (will be used by all instances of CKEditor).
$CKEditor->config['width'] = 600;
// Change default textarea attributes
$CKEditor->textareaAttributes = array(“cols” => 80, “rows” => 10);
$CKEditor->replace("pagecontent");
$sbmt_caption = "continue ->";
if ($_POST["submit_name"]==$sbmt_caption)
{
$prname = mysql_real_escape_string ($_POST["pr-name"]);
$prend = mysql_real_escape_string ($_POST["pr-end"]);
$prmenu = "pdf";
$prcontent = mysql_real_escape_string ($_POST["pagecontent"]);
$sql = "INSERT INTO projects (pr-name,enddate, sel, content) VALUES('$prname','$prend', '$prmenu', '$prcontent')";
$result = mysql_query($sql);
if (!$result){
echo mysql_error();
}
}
?>
“/>
this code with the mysql_query bit even doesn’t work for me some reason.
Could anyone give me some hint?
Four tips:
Check if your query success and ouput errors if any with
Use prepared statements instead of direct embedding parameters into a query string
Use
$_POSTinstead of$_REQUEST.$_REQUESTarray is build up from cookie,get,post and session according tovariables_orderphp.ini directive, so you may just get your values overwritten.your submit button is not posted at all. So add
nameattribute to it and check it in your if statement. Also, don’t use just plain stringcontinue ->. Store it in the variable and use it.