PHP to reload page from modal - php

i am trying to reload page using onClick="location.href='Edit_Equip.php?txtidforsite='" /> but i get Notice: Undefined variable: id
i have tried to define id but still get errors any help would be great
<?php
include('connect.php');
if(isset($_POST['txtidforsite']))
{
$id=$_POST['txtidforsite'];
if(isset($_POST['submit']))
{
$query3 = mysql_query("UPDATE ftn_site_equip SET siteidequip='".$_POST['txtidforsite']."', patype='".$_POST['txtpa']."', drxtype='".$_POST['txtdrx']."' WHERE siteidequip='$id'");
if($query3)
{
header('refresh:2; url=#openModa3');
}
}
$query1=mysql_query("select * from ftn_site_equip where siteidequip='$id'");
$query2=mysql_fetch_array($query1);
?>
<form method="post" action="" align="center">
<input name="txtidforsite" value="<?php echo $query2['siteidequip']; ?>" size="36" class="siteinfotable"/>
<input name="txtdrx" value="<?php echo $query2['drxtype']; ?>" size="36" class="siteinfotable"/>
<input name="txtpa" value="<?php echo $query2['patype']; ?>" size="36" class="siteinfotable"/>
<input type="submit" name="submit" class="update_record_button" value="Update Record" onclick="window.location='#openModal2';" />
</form>
<?php
}
?>
<div id="openModal" class="cancel_modal">
<div align="center">
<h2 align="center">Are you sure you want to cancel all changes ?</h2>
<input name="yes" type="button" value="Yes" class="yes_button" onClick="location.href='Edit_Form.php?txtid='" />
<input name="no" type="button" value="No" class="no_button" onclick="location.href='#close'"/>
</div>
</div>
<div id="openModal2" class="cancel_modal">
<div align="center">
<img alt="" src="Images/tick.jpg"/><br/>
<h2 align="center">Record Successfully Updated</h2>
</div>
</div>
<div id="openModa3" class="cancel_modal">
<div align="center">
<h2 align="center">What Next ?</h2>
<input name="yes" type="button" value="Retrun to Site Information" class="yes_button" onClick="location.href='Edit_Equip.php?txtidforsite=<?php echo $id; ?>'" />
<input name="no" type="button" value="Search for Another Site" class="no_button" onclick="location.href='search.php'"/>
</div>
</div>

Related

Cannot display edit form when clicked on edit button and the form doesn't parse error and displays blank page

EDIT: My edit button refuse to work.
I'm trying to edit this page, but it seems to be breaking when I click the edit button. it is retrieving data from the database and displaying on faculty.php successfully while if I try to edit it shows a blank page. what is wrong with my code, please.
faculty.php: a separate page where i have my edit button
<td>
<form action="facultyedit.php" method="POST">
<input type="hidden" name="edit_id" value="<?php echo $row['id']; ?>" >
<button type="submit" name="edit_data_btn" class="btn btn-success">EDIT</button>
</form>
</td>
facultyedit page: where i receive the edit button
<?php
if (isset($_POST['edit_data_btn']))
{
$id = $_POST['edit_id'];
$query = " SELECT * FROM register WHERE id='$id' ";
$query_run = mysqli_query($connection, $query);
foreach ($query_run as $row ) {
?>
<form action="" method="POST" >
<input type="text" name="edit_id" value="<?php echo $row['id'] ?>" >
<div class="form-group">
<label>Name:</label>
<input type="text" name="edit_name" value="<?php echo $row['name']; ?>" class="form-control" >
</div>
<div class="form-group">
<label>Designation:</label>
<input type="text" name="edit_designation" value="<?php echo $row['design']; ?>" class="form-control" >
</div>
<div>
<label>Description:</label>
<input type="text" name="edit_description" value="<?php echo $row['descrip']; ?>" class="form-control" >
</div>
<div class="form-group">
<label>Upload Image:</label>
<input type="file" name="edit_faculty_image" id="faculty_image" value="<?php echo $row['image']; ?>" class="form-control" >
</div>
<div class="">
Cancel
<button type="update" name="update_aboutusbtn" class="btn btn-primary">Update</button>
</div>
</form>
<?php
}
}
?
I have fixed the issue:
The problem was that I was selecting a register table from the database instead of the faculty table.

my page is not redirecting properly

I have a popup which shows up if the user is not logged in. It contains a cancel link, a form to enter details, and a forget password link. My problem is when the user comes back from the forget password link and clicks the cancel link, it takes them back to the forget password page.
Here is my code.
<div class="contactForm_new" id="popUpDiv" style="display:none;">
<!--<div class="lightBlue heading" >Tell us your Buy Requirement</div>-->
<div class="blueLightBG heading" style="text-align: left;
padding-left: 2%;background-color:#009bcb ">Enter Password <span class=" dpbl fr mainSp cr_bt2 p_a closeTrigger closePopup href" style="position: absolute; display: block;"></span></div>
<form method="post" class="contactF" id="login-form">
<input type="hidden" value="" name="offerid">
<input type="hidden" value="" name="refvalue">
<input type="hidden" value="" name="tenderid">
<input type="hidden" value="" name="item_id">
<input type="hidden" value="" name="pid">
<input type="hidden" value="sd" name="ref">
<input type="hidden" value="1" name="isLogRequest">
<input type="hidden" name="iso" id="iso" value="<?php echo $details['iso'] ?>">
<input type="hidden" value="<?php echo $return_en_url ?>" id="p_address" name="p_address">
<div class="errorMessage" id="errorUsername"></div>
<input type="hidden" name="diff_usr" value="Y">
<input type="hidden" value="Y" name="diff_usr">
<input class="pd3 textlogin_new" name="LoginForm[password]" id="LoginForm_password" type="password">
<div class="errorMessage" id="errorPassword"></div>
<div style="padding:15px 0;text-align:center">
<span id="imgprcp" class="fl" style=" display: none; text-align: center;margin-left:50%;"><img src="<?php echo Yii::app()->params['hostName'] ?>/images/ind.gif" alt="Proceeding"></span>
<input id="btnSubmit" type="button" name="yt0" value="Proceed" class="redBtn_new" >
</div>
<div class="mb3per" style="display:block">
<p class="k7_new" style="position:absolute;" >
<a class="k7_new" id="forgotpass" style="position:relative;" href="<?php echo Yii::app()->params['hostName'] ?>/forgotpass/?ref=<?php echo $ref ?>&p=<?php echo $return_en_url ?>" >Forgot Password?</a>
</p>
</div>
</form>
</div>
Can anybody suggest what am I doing wrong? All of my URLs are formed correctly.This problem is coming in only chrome browser.In another browser it is working fine

php isset not working properly echo back empty

in my code when i click on submit 3 btn it echos back empty $email though post is created in db the title is always empty, however if i change if(isset($_POST['submit3'])) to if(isset($_POST['submit1'])), it doesn't enter the details into db or echo back anything
<script type="text/javascript">
$( document ).ready(function() {
$("#form1").show();
$("#form2").hide();
$("#form3").hide();
$('button[name="submit1"]').click(function(e) {
$("#form2").show();
$("#form1").hide();
$("#form3").hide();
e.preventDefault();
});
$('button[name="submit2"]').click(function(e) {
$("#form3").show();
$("#form1").hide();
$("#form2").hide();
e.preventDefault();
});
});
</script>
<body>
<form id="form1" method="post" >
<div>
<input type="text" id="inputemail" name="email" placeholder="Email" height="34px" >
</div>
<div >
<button id="submit1" type="submit" name="submit1" ><strong>Start</strong></button>
</div>
</form>
<form id="form2" method="post" style="display:none">
<div>
<input type="text" id="inputpwd" name="pwd" placeholder="Password" height="34px" required>
</div>
<div >
<button id="submit2" type="submit" name="submit2" ><strong>Next</strong></button>
</div>
</form>
<form id="form3" method="post" style="display:none">
<div required>
<input type="checkbox" value="0" name="book_type[]"> Romance</input><br>
<input type="checkbox" value="1" name="book_type[]"> Action</input><br>
<input type="checkbox" value="2" name="book_type[]"> suspense</input><br>
<input type="checkbox" value="3" name="book_type[]"> thriller</input><br>
</div>
<div >
<button id="submit3" type="submit" name="submit3" onclick="submitform();"><strong>Next</strong></button>
</div>
</form>
</body>
<?php
$email=$_POST['email'];
$pwd=$_POST['pwd'];
$bookchk=array();
$todaydate = new DateTime();
$todaydate =$todaydate->format('Y-m-d H-i-s');
if(isset($_POST['submit3']))
{
echo $email;
$formarg= array('post_type'=>'details',
'post_title'=>$email,
'post_author'=>'1',
'post_status'=>'publish',
'post_date'=>$todaydate );
$wpdb->insert('wp_posts',$formarg);
$bookpostid=$wpdb->insert_id;
foreach($_POST['book_type'] as $selectedplan)
{
$bookchk[]=$selectedplan;
}
update_field('field_561b9999ebb56',$bookchk[0],$contestpostid);
update_field('pwd',$pwd,$bookpostid);
}
?>
Try it:
<button id="submit3" type="submit" name="submit3" value="Next" onclick="submitform();"><strong>Next</strong></button>
<?php
session_start();
if(isset($_POST['email'])){$_SESSION["email"] = $_POST['email'];}
if(isset($_POST['pwd'])){$_SESSION["pwd"] = $_POST['pwd'];}
if(isset($_POST['book_type'])){$_SESSION["book_type"] = $_POST['book_type'];}
if(isset($_SESSION["email"]) && isset($_SESSION["pwd"]) && isset($_SESSION["book_type"])){
echo "email:".$_SESSION["email"]."<br>";
echo "pwd:" .$_SESSION["pwd"]."<br>";
echo("options:");
for($i=0;$i<sizeof($_SESSION["book_type"]);$i++){
echo $_SESSION["book_type"][$i]."|";
}
session_destroy();
$_SESSION["email"] = "";
$_SESSION["pwd"] = "";
$_SESSION["book_type"] = "";
}
$todaydate = new DateTime();
$todaydate =$todaydate->format('Y-m-d H-i-s');
?>
<body>
<?php if(empty($_SESSION["email"])):?>
<form id="form1" method="post">
<div>
<input type="text" id="email" name="email" placeholder="Email" height="34px" >
</div>
<div >
<input id="submit1" type="submit" name="submit1" value = "Start">
</div>
</form>
<?php endif;?>
<?php if(isset($_SESSION["email"]) && empty($_SESSION["pwd"]) ):?>
<form id="form2" method="post">
<div>
<input type="text" id="pwd" name="pwd" placeholder="Password" height="34px" required>
</div>
<div >
<input id="submit2" type="submit" name="submit2" value = "Next">
</div>
</form>
<?php endif;?>
<?php if(isset($_SESSION["email"]) && isset($_SESSION["pwd"]) && empty($_SESSION["book_type"])):?>
<form id="form3" method="post">
<div required>
<input type="checkbox" value="0" name="book_type[]"> Romance</input><br>
<input type="checkbox" value="1" name="book_type[]"> Action</input><br>
<input type="checkbox" value="2" name="book_type[]"> suspense</input><br>
<input type="checkbox" value="3" name="book_type[]"> thriller</input><br>
</div>
<div >
<button id="submit3" type="submit" name="submit3" onclick="submitform();"><strong>Next</strong></button>
</div>
</form>
<?php endif;?>
</body>
You are getting back empty $email when submitting through button
id="submit3" because an input field with attribute name="email"
doesn't exists within your third form <form id="form3" ...> </form>
You are receving nothing when submitting through button
id="submit1" because e.preventDefault(); method prevents form from
submitting when you click submit button.
To proceed submitting of your first and second form remove e.preventDefault(); from submit button click handlers

Stuck at one simple PHP UPDATE table, UPDATE just do nothing

This code is just refreshing my page. I cant see any errors. Maybe someone else can see the error here in code? I have the same code in two other pages and they do UPDATE.
The code below is in one page:
<body>
<?php
$query=mysqli_connect("localhost","user","","mydb") or die ("Ne moga da se svyrja s bazata danni.");
if(isset($_GET['id']))
{
$id=$_GET['id'];
if(isset($_POST['submit']))
{
$datetime=$_POST['datetime'];
$vlekach_teltur=$_POST['vlekach_teltur'];
$driver1=$_POST['driver1'];
$telnomer=$_POST['telnomer'];
$belejka=$_POST['belejka'];
$user=$_POST['user'];
mysqli_set_charset($query,"utf8");
$sql="update teltur set datetime = '$datetime', vlekach_teltur = '$vlekach_teltur', driver1 = '$driver1', telnomer = '$telnomer', belejka = '$belejka', user = '$user' where id='$id'";
$query3 = mysqli_query($query, $sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error(), E_USER_ERROR);
if(mysqli_query($query3, $sql)){
echo "
<!DOCTYPE html>
<script>
function redir()
{
alert('Успешен запис!');
window.location.assign('index.php');
}
</script>
<body onload='redir();'></body>";
}
else{
echo "Не успешен запис, свържете се с администратора $query3. " . mysqli_error($query);
}
}
mysqli_set_charset($query,"utf8");
$sql2="select * from teltur where id='$id'";
$query1=mysqli_query($query, $sql2);
$query2=mysqli_fetch_array($query1);
?>
<h3 style="text-align:center;">Редакция на телефони Турция</h3>
<form id="docContainer" class="fb-toplabel fb-100-item-column selected- object" enctype="multipart/form-data" method="post" action="">
<div id="section1" class="section">
<div id="column1" class="column ui-sortable">
<div class="fb-grouplabel">
<p>Дата<input type="text" id="datetime" name="datetime" value="<?php echo $query2['datetime']; ?>"/>
<label id="datecheckalert" style="color: red; font-style: italic;"> </label></p>
</div>
<p>Влекач:
<input type="text" name="typeahead" class="typeahead tt-query" autocomplete="on" spellcheck="false" value="<?php echo $query2['vlekach_teltur']; ?>">
</p>
<div id="scrollable-dropdown-menu">
<p>Шофьор:
<input type="text" name="driver1" class="driver1 tt-query" autocomplete="on" spellcheck="false" value="<?php echo $query2['driver1']; ?>">
</p>
</div>
<div id="scrollable-dropdown-menu">
<p>Телефонен номер:
<input type="text" name="telnomer" class="telnomer tt-query" autocomplete="on" spellcheck="false" value="<?php echo $query2['telnomer']; ?>"/>
</p>
</div>
<p>Забележка:
<input type="text" name="belejka" value="<?php echo $query2['belejka']; ?>"/>
</p>
<p>Потребител:
<select id="user" name="user">
<option value="<?php echo $query2['user']; ?>"><?php echo $query2['user']; ?></option>
</select></p>
<p align="center">
<input type="submit" value="ЗАПИС" />
</p>
</div>
</div>
<?php
}
?>
</form>
</body>
I have error reporting as you see but no errors found.
Yeah im so stupid, i missed to name the Submit button.
<input type="submit" value="ЗАПИС" />
Changed to this code: <input type="submit" name="submit" value="ЗАПИС" />
I spend tree hours and after make a post here i found it by my self.
Can some one just delete this thread?

username and password help in joomla

What I'm trying to do here is display my login information and once logged in display something else
Example is here
<?php
$user = JFactory::getUser();
$status = $user->guest;
if($status == 1){
echo '
<form id="login-form" class="form-inline" method="post" action="/home">
<div class="topUser">
Name:
<input id="modlgn-username" class="TopinputReg" type="text" placeholder="User Name" tabindex="0" name="username" />
</div>
<div class="toppass">Password:
<input id="modlgn-passwd" class="TopinputReg" type="password" placeholder="Password" tabindex="0" name="password" pwfprops="," />
</div>
<div class="topsignin">
<input class="Signin" name="Submit" tabindex="0" type="submit" value="" />
</div>
<div class="topregister">
<input name="button" type="submit" class="Register" id="button" value="" />
</div>
<input type="hidden" value="com_users" name="option">
<input type="hidden" value="user.login" name="task">
<input type="hidden" value="aW5kZXgucGhwP0l0ZW1pZD0xMzM=" name="return">
<input type="hidden" value="1" name="39ea5446d876078c6f6221d396ef5bd4">
</form>
';
}
else
{
echo '
<div class="topUser">Welcome Back!</div>
<div class="toppass">Enjoy you stay.</div>
<form id="login-form" class="form-vertical" method="post" action="/log-out">
<div class="topsignin">
<input class="Signout" type="submit" value="" name="Submit" />
<input type="hidden" value="com_users" name="option">
</div>
<input type="hidden" value="com_users" name="option">
<input type="hidden" value="user.logout" name="task">
<input type="hidden" value="aW5kZXgucGhwP0l0ZW1pZD0xMDE=" name="return">
<input type="hidden" value="1" name="994c61f8ab4ccf23fe9dae6546a87089">
</form>
<div class="topregister">
<input name="button" type="submit" class="account" id="button" value="" />
</div>
';
}
?>
No I know what I am doing wrong just have no clue how to fix it. the two
need to have a different generated number each time but how do i do this.
since this numbers are the same every time if i log in then out then try to log back in it will give me "Invalid Token"
When i go into the login template it gives me
this for login
<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>
and this for log out
<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('logout_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>
Now if I replace the hidden fields that already have the pregenerated numbers with the php stuff above when i try to refresh my page it goes completely blank.
I am at a loss with this see as how I am not very advanced in php. any help anyone cant provide would be massively helpful..
why not try like this,
<?php
$user = JFactory::getUser();
$status = $user->guest;
if($status == 1):
?>
<form id="login-form" class="form-inline" method="post" action="/home">
<div class="topUser">
Name:
<input id="modlgn-username" class="TopinputReg" type="text" placeholder="User Name" tabindex="0" name="username" />
</div>
<div class="toppass">Password:
<input id="modlgn-passwd" class="TopinputReg" type="password" placeholder="Password" tabindex="0" name="password" pwfprops="," />
</div>
<div class="topsignin">
<input class="Signin" name="Submit" tabindex="0" type="submit" value="" />
</div>
<div class="topregister">
<input name="button" type="submit" class="Register" id="button" value="" />
</div>
<input type="hidden" value="com_users" name="option">
<input type="hidden" value="user.login" name="task">
<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>
<?php else:
?>
<div class="topUser">Welcome Back!</div>
<div class="toppass">Enjoy you stay.</div>
<form id="login-form" class="form-vertical" method="post" action="/log-out">
<div class="topsignin">
<input class="Signout" type="submit" value="" name="Submit" />
<input type="hidden" value="com_users" name="option">
</div>
<input type="hidden" value="com_users" name="option">
<input type="hidden" value="user.logout" name="task">
<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('logout_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>
<div class="topregister">
<input name="button" type="submit" class="account" id="button" value="" />
</div>
<?php endif;?>

Categories