php - Blank Page after pressing Submit button with all fields filled up -
as shown in title, have page users create projects , page add database. when press submit form fields empty, page post isn't blank. when submit fields filled up, shows blank page without errors , have looked through both pages of codes can't seem find wrong. perhaps here me out? thanks.
//codes on page data submitted.
if ($_post['projecttitle'] != "" && $_post['projectstatus'] != "" && $_post['projectdesc'] != "" && $_post['projectdeliv'] != "" && $_post['year'] != "" && $_post['month'] != "" && $_post['day'] != "" && $_post['projectss'] != "") { $host = "localhost"; $user = "root"; $pass = ""; $db = "fyp1"; $pt = $_post['projecttitle']; $ps = $_post['projectstatus']; $pdes = $_post['projectdesc']; $pdel = $_post['projectdeliv']; $date = $_post['year'] . "-" . $_post['month'] . "-" . $_post['day']; $pss = $_post['projectss']; date_default_timezone_set('utc+8'); $cdate = date('y-m-d'); $uid = $_session['id']; $link = mysqli_connect($host, $user, $pass, $db) or die(mysqli_error()); $query = "select * project project_title = $pt , project_description = $pdes , project_deliverables = $pdel , project_skillset = $pss"; $dub = mysqli_query($link, $query) or die(mysqli_connect_error($link)); if (mysqli_num_rows($dub) == 0) { $insertq = "insert project(project_title,project_description,project_deliverables,project_start,project_end,project_skillset,project_status) values ('$pt','$pdes','$pdeliv','$cdate','$date','$pss',$ps)"; mysqli_query($link, $insertq) or die(mysqli_connect_error($link)); $getpid = "select * project project_title = $pt , project_description = $pdes , project_deliverables = $pdel , project_start = $cdate , projecct_end = $date , project_skillset = $pss"; $pid = mysqli_query($link, $getpid) or die(mysqli_connect_error($link)); if (mysqli_num_rows($pid) == 1) { while ($row = mysqli_fetch_array($pid)) { $proid = $row['project_id']; $insertf = "insert user_has_project(user_id,project_id) values ('" . $uid . "','" . $proid . "')"; mysqli_query($link,$insertf) or die(mysqli_connect_error($link)); $message = "<p>project added!</p>"; $message .= "<a href='index.php'>back</a>"; $a = true; } } else { $message = "<p>project failed added!</p>"; $message .= "<a href='createproject.php'>back</a>"; $a = false; } } else { $message = "<p>duplicate project found!</p>"; $message .= "<a href='createproject.php'>back</a>"; $a = false; } } else { $message = "<p>please fill fields when creating project!</p>"; $message .= "<a href='createproject.php'>back</a>"; $a = false; }
// codes on page form
<div id="content"> <?php if ($a == false) { ?> <h2 id="registerfont">create project</h2> <form name="createproject" method="post" action="docreateproject.php" onsubmit="return validateform(this);"> <fieldset> <table> <tr> <th colspan="4"><h2>new project</h2></th> </tr> <tr> <th colspan="4"><hr /></th> </tr> <tr> <td><label for="projecttitle">project title:</label></td><td><input name="projecttitle" type="text" /></td> <td><label for="projectstatus">project status:</label></td> <td><select name="projectstatus"> <?php while ($row = mysqli_fetch_array($result1)) { ?> <option value="<?php echo $row['status_id']; ?>" ><?php echo $row['status_type']; ?></option> <?php } ?> </select></td> </tr> <tr> <td><label for="projectdesc">project description:</label></td><th colspan="3"><textarea name="projectdesc" rows="5" cols="40" ></textarea></th> </tr> <tr> <td><label for="projectdeliv">project deliverables:</label></td><th colspan="3"><textarea name="projectdeliv" rows="5" cols="40" ></textarea></th> </tr> <tr> <td>start date:</td><td><?php echo $date; ?></td> </tr> <tr> <td>end date : </td> <th colspan="3" align="left"> <select name="year"> <option>---year---</option> <?php ($i = $cyear; $i < ($cyear + 100); $i++) { ?> <option value="<?php echo $i; ?>"><?php echo $i; ?></option> <?php } ?> </select> <select name="month"> <option>---month---</option> <?php while ($rows = mysqli_fetch_array($result)) { ?> <option value="<?php echo $rows['month_id']; ?>"><?php echo $rows['month']; ?></option> <?php } ?> </select> <select name="day"> <option>---day---</option> <?php ($i = 1; $i < 32; $i++) { ?> <option value="<?php echo $i ?>"><?php echo $i ?></option> <?php } ?> </select> </th> </tr> <tr> <td><label for="projectss">project skill set:</label></td><td><input name="projectss" type="text"/></td><th colspan="2"><small>(please separate comma)</small></th> </tr> </table> </fieldset> <br /> <input name="submit" type="submit" value="create project" /> </form> <?php } else { echo $message; } ?> </div>
i managed solve problem. when querying database, @ select statement, variables forgot add ''. e.g select * project project_title = '$variable';
anyways. helped out. appreciate it.
Comments
Post a Comment