php - Refresh on submit behaving weirdly -
i expect below code cause page refresh when pressed of called or emailed buttons not appear doing so. click button , page not refresh when press f5 change shows relevant field.
can offer thoughts on why it's not refreshing? need force whole page refresh whenever submit button clicked. i'm open js solutions quirky behavior making hard figure out what's going on. help!
<html> <head> <title>call log system</title> <style type="text/css"> @-webkit-keyframes invalid { { background-color: red; } { background-color: inherit; } } @-moz-keyframes invalid { { background-color: red; } { background-color: inherit; } } @-o-keyframes invalid { { background-color: red; } { background-color: inherit; } } @keyframes invalid { { background-color: red; } { background-color: inherit; } } .invalid { -webkit-animation: invalid 3s infinite; /* safari 4+ */ -moz-animation: invalid 3s infinite; /* fx 5+ */ -o-animation: invalid 3s infinite; /* opera 12+ */ animation: invalid 3s infinite; /* ie 10+ */ } </style> <script language="javascript" type="text/javascript"> function checkdelete(){ return confirm('are sure want delete record?'); } </script> <script language="javascript" type="text/javascript"> function checkarchive(){ return confirm('are sure want archive record?'); } </script> </head> <body> <?php $db_host = 'localhost'; $db_user = '********'; $db_pwd = '******'; $database = '********'; $table = 'project_submissions'; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("can't connect database"); if (!mysql_select_db($database)) die("can't select database"); //display fields $result = mysql_query("select * {$table} archived null or archived='' order id desc"); if (!$result) { die("query show fields table failed"); } echo "<a href=\"archives.php\">go archives</a>"; //main table echo "<table border='1px' width='100%'> <tr> <th style='font-size:18px;width:20px;'>id</th> <th style='font-size:18px;'>customer name</th> <th style='font-size:18px;'>phone #</th> <th style='font-size:18px;'>address</th> <th style='font-size:18px;'>time zone</th> <th style='font-size:18px;'>e-mail</th> <th style='font-size:18px;'>alt phone</th> <th style='font-size:18px;'>vehicle</th> <th style='font-size:18px;'>project start</th> <th style='font-size:18px;'>project description</th> <th style='font-size:18px;'>rdm</th> <th style='font-size:18px;'>phone call #1</th> <th style='font-size:18px;'>phone call #2</th> <th style='font-size:18px;'>phone call #3</th> <th style='font-size:18px;'>email sent</th> <th style='font-size:18px;'>notes</th> <th style='font-size:18px;'>received date</th> <th style='font-size:18px;'>functions</th> </tr>"; while ($row = mysql_fetch_array($result)) { $mydate = $row['received_date']; $receiveddate = strtotime($mydate); $onemonthago = strtotime('-1 month'); $twomonthago = strtotime('-2 month'); $threemonthago = strtotime('-3 month'); if($receiveddate > $onemonthago)//less 30 days old { echo "<tr bgcolor=\"#74ed45\">";//green } else if(($receiveddate > $twomonthago) && ($receiveddate < $onemonthago))//30-60 days old { echo "<tr bgcolor=\"#eded45\">";//yellow } else if(($receiveddate > $threemonthago) && ($receiveddate < $twomonthago))//60-90 days old { echo "<tr bgcolor=\"#d65151\">";//red } else if($receiveddate < $threemonthago)//more 90 days old { //echo "<tr bgcolor=\"#2c32db\">";//blue echo "<tr class=\"invalid\">";//flashing red } else { echo "<tr>"; } echo " <td style='font-size:12px;'><center>{$row['id']}</center></td> <td style='font-size:12px;'>{$row['first_name']} {$row['last_name']}</td> <td style='font-size:12px;'><center><a href=\"tel:{$row['phone']}\">{$row['phone']}</a></center></td> <td style='font-size:12px;'><center>{$row['street']} {$row['city']} {$row['state_country']}</center></td> <td style='font-size:12px;'><center><div style=\"width:150px\">{$row['time_zone']}</div></center></td> <td style='font-size:12px;'><center><a href=\"mailto:{$row['email']}?subject=************\" target=\"_top\">{$row['email']}</a></center></td> <td style='font-size:12px;'><center>{$row['alt_phone']}</center></td> <td style='font-size:12px;'><center>{$row['year']} {$row['make']} {$row['model']}</center></td> <td style='font-size:12px;'><center>{$row['project_start']}</center></td> <td style='font-size:12px;width:300px;'><div style=\"overflow-x:auto; max-height:100px\">{$row['project_description']}</div></td> <td style='font-size:12px;'><center>{$row['restoration_decision_matrix']}</center></td> <td style='font-size:12px;'><center>"; //------------------------------------ if(empty($row['callattemptone'])) { echo" <form action='".$_server['php_self']."' method='post'> <input type='hidden' id='id' name='id' value='{$row['id']}' /> <input type='submit' name='formcalledone' id='formcalledone' value='called' /> </form> {$row['callattemptone']}"; } else { echo "{$row['callattemptone']}"; } echo "</center></td><td style='font-size:12px;'><center>"; //------------------------------------ if(empty($row['callattempttwo'])) { echo" <form action='".$_server['php_self']."' method='post'> <input type='hidden' id='id' name='id' value='{$row['id']}' /> <input type='submit' name='formcalledtwo' id='formcalledtwo' value='called' /> </form> {$row['callattempttwo']}"; } else { echo "{$row['callattempttwo']}"; } echo "</center></td><td style='font-size:12px;'><center>"; //------------------------------------ if(empty($row['callattemptthree'])) { echo" <form action='".$_server['php_self']."' method='post'> <input type='hidden' id='id' name='id' value='{$row['id']}' /> <input type='submit' name='formcalledthree' id='formcalledthree' value='called' /> </form> {$row['callattemptthree']}"; } else { echo "{$row['callattemptthree']}"; } echo "</center></td><td style='font-size:12px;'><center>"; //------------------------------------ if(empty($row['emailattempt'])) { echo" <form action='".$_server['php_self']."' method='post'> <input type='hidden' id='id' name='id' value='{$row['id']}' /> <input type='submit' name='formemailattempt' id='formemailattempt' value='emailed' /> </form> {$row['emailattempt']}"; } else { echo "{$row['emailattempt']}"; } echo "</center></td> <td style='font-size:12px;width:300px;'><center>text area</center></td> <td style='font-size:12px;'><center>{$row['received_date']}</center></td> <td style='font-size:12px;'><center> <form action='".$_server['php_self']."' method='post' onclick=\"return checkdelete()\"> <input type='hidden' id='id' name='id' value='{$row['id']}' /> <input type='submit' name='formdelete' id='formdelete' value='delete' /> </form> <form action='".$_server['php_self']."' method='post' onclick=\"return checkarchive()\"> <input type='hidden' id='id' name='id' value='{$row['id']}' /> <input type='submit' name='formarchive' id='formarchive' value='archive' /> </form> </center></td> </tr>"; //check see if delete button pressed if(isset($_post['formdelete'])) { if(isset($_post['id']) && !empty($_post['id'])) { $deleteid = $_post['id']; $result = mysql_query("delete project_submissions id ='".$deleteid."'"); } } //check see if archive button pressed if(isset($_post['formarchive'])) { if(isset($_post['id']) && !empty($_post['id'])) { $archiveid = $_post['id']; $result = mysql_query("update project_submissions set archived ='1' id ='".$archiveid."'"); } } if(isset($_post['formcalledone']))//check see if call attempt 1 button pressed { //if(isset($_post['id']) && !empty($_post['id'])) //{ $callattemptoneid = $_post['id']; $callattemptonequery = mysql_query("update project_submissions set callattemptone=curdate() id ='".$callattemptoneid."' , (callattemptone null or length(callattemptone)=0)"); //} } if(isset($_post['formcalledtwo']))//check see if call attempt 2 button pressed { //if(isset($_post['id']) && !empty($_post['id'])) //{ $callattempttwoid = $_post['id']; $callattempttwoquery = mysql_query("update project_submissions set callattempttwo=curdate() id ='".$callattempttwoid."' , (callattempttwo null or length(callattempttwo)=0)"); //} } if(isset($_post['formcalledthree']))//check see if call attempt 3 button pressed { if(isset($_post['id']) && !empty($_post['id'])) { $callattemptthreeid = $_post['id']; $callattemptthreequery = mysql_query("update project_submissions set callattemptthree=curdate() id ='".$callattemptthreeid."' , (callattemptthree null or length(callattemptthree)=0)"); } } if(isset($_post['formemailattempt']))//check see if email attempt button pressed { if(isset($_post['id']) && !empty($_post['id'])) { $emailattemptid = $_post['id']; $emailattemptquery = mysql_query("update project_submissions set emailattempt=curdate() id ='".$emailattemptid."' , (emailattempt null or length(emailattempt)=0)"); } } } ?> </body> </html>
if understood question, think should help.
<?php $value = "string"; if (isset($_post['id'])) { echo $emailattemptid = $_post['id']; } echo" <form action='".$_server['php_self']."' method='post'> <input type='hidden' id='id' name='id' value='$value' /> <input type='submit' name='formemailattempt' id='formemailattempt' value='emailed' /> </form> "; ?>
Comments
Post a Comment