Jump to content

Submit button doesn't work, weird


AV

Recommended Posts

Hi everybody, I got script alike this:

<?php
include('../config.php');
include('../functions.php');
session_start();
db();
?>
<?php include('../templates/header.html'); ?>
<?php
if(isset($_SESSION['correct']))
{
    echo '<div id="done">User logged as: '.$_SESSION['correct'].'</div>';
?>
<div id="menu">
    <img src="../templates/images/menu.png" alt="Menu" />
    <ul>
        <li><a href="index.php">Home</a></li>
        <li><a href="logout.php">Logout</a></li>
    </ul>
</div>
<div id="about">
    <img src="../templates/images/manage_users.png" alt="Manage users" />
    <div id="text_about";
<form method="post" action="index.php">
<table>
<tr><td>New password:</td>
<td><input type="text" name="new" class="login"></td></tr>
<tr><td>Confirm password:</td>
<td><input type="password" name="new2" class="login"></td></tr>
<tr><td colspan="2" align="center">
<input type="submit" name="submit" value="Change" class="login_button"></td></tr>
</table></form>
<?php
    
    if(isset($_POST['submit'])) {
    
      $new = $_POST['new'];
      $new2 = $_POST['new2'];    
    
      if($new == $new2 && !$new2=''){
    
       $new_pass = sha1($new2);
       $login = $_SESSION['correct'];
       $result = mysql_query("UPDATE users SET pass='$new_pass' WHERE login='$login'")
       or die(mysql_error());
       if(!$result){ echo 'Changing password phailed'; }else{ echo 'Done!'; }
    
      }else{ echo '<br />Passwords dont match!'; }
    }
    
?>
    </div>
</div>
<?php
}
else
{
    echo '<div id="warning">*beep* Access denied!<br /><br />';
    echo '<a href="login.php">LOG IN</a></div>';
}
?>
<?php include('../templates/footer.html'); ?>

The problem is that the submit button doesn't work after clicking it. Any ideas what is wrong?

Link to comment
Share on other sites

Have you tried stripping out the includes, and other items, getting to the bare essentials? Once you know it's working from there, start adding things back until it doesn't work.

 

Also, did you try print_r($_POST); to see if anything was being posted?

Link to comment
Share on other sites

 

not your form m8....

<?php

if($_POST['submit']){

$new=$_POST['new'];

$new2=$_POST['new2'];

if($new==$new2){

	echo correct;
}else{

echo incorrect;
}
  }
?>

<form method="POST" action=" ">
<table>
<tr><td>New password:</td>
<td><input type="text" name="new" class="login"></td></tr>
<tr><td>Confirm password:</td>
<td><input type="password" name="new2" class="login"></td></tr>
<tr><td colspan="2" align="center">
<input type="submit" name="submit" value="Change" class="login_button"></td></tr>
</table></form>

Link to comment
Share on other sites

get rid off this part then try like my example...

 

&& (!$new2=''))

 

 

<?php

if($_POST['submit']){

$new=$_POST['new'];

$new2=$_POST['new2'];

	if(empty($new) || (empty($new2))){

		echo "Sorry fill in all the dam form! <br>";
		}
		if( ($new==$new2)){
     
echo correct;

}else{

echo incorrect;
}
  }

  ?>

<form method="POST" action=" ">
<table>
<tr><td>New password:</td>
<td><input type="text" name="new" class="login"></td></tr>
<tr><td>Confirm password:</td>
<td><input type="password" name="new2" class="login"></td></tr>
<tr><td colspan="2" align="center">
<input type="submit" name="submit" value="Change" class="login_button"></td></tr>
</table></form>

 

 

as soon as you do this it will work!

 

<?php include('../templates/header.html'); ?>
<?php
if(isset($_SESSION['correct']))
{
    echo '<div id="done">User logged as: '.$_SESSION['correct'].'</div>';
?>
<div id="menu">
    <img src="../templates/images/menu.png" alt="Menu" />
    <ul>
        <li><a href="index.php">Home</a></li>
        <li><a href="logout.php">Logout</a></li>
    </ul>
</div>
<div id="about">
    <img src="../templates/images/manage_users.png" alt="Manage users" />
    <div id="text_about";
<form method="post" action="index.php">
<table>
<tr><td>New password:</td>
<td><input type="text" name="new" class="login"></td></tr>
<tr><td>Confirm password:</td>
<td><input type="password" name="new2" class="login"></td></tr>
<tr><td colspan="2" align="center">
<input type="submit" name="submit" value="Change" class="login_button"></td></tr>
</table></form>
<?php
    
    if(isset($_POST['submit'])) {
    
      $new = $_POST['new'];
      $new2 = $_POST['new2'];    
    
      if($new == $new2){
    
       $new_pass = sha1($new2);
       $login = $_SESSION['correct'];
       $result = mysql_query("UPDATE users SET pass='$new_pass' WHERE login='$login'")
       or die(mysql_error());
       if(!$result){ echo 'Changing password phailed'; }else{ echo 'Done!'; }
    
      }else{ echo '<br />Passwords dont match!'; }
    }
    
?>
    </div>
</div>
<?php
}
else
{
    echo '<div id="warning">*beep* Access denied!<br /><br />';
    echo '<a href="login.php">LOG IN</a></div>';
}
?>
<?php include('../templates/footer.html'); ?>

Link to comment
Share on other sites

redarrow, it still doesn't work

I tried as tgavin said, adding print_r($_POST) to the script but nothing happens.

 

I forgot to say that the whole code I posted here it is index.php

 

Any ideas??

Link to comment
Share on other sites

redarrow, it still doesn't work

 

Define what "doesn't work" means. Define what you mean by "the submit button doesn't work after clicking it".  neither of those is much help.  Something must happen. Presumably it isn't what you expect or hoped for, but what does happen?  I suspect your logic is flawed.

Link to comment
Share on other sites

Is this really hard to understand that after I click the button nothing happen!

Nothing change!!

Yeah, it is hard to understand, because a submit button should submit.

 

a few questions.

1. Are you trying this on a live web server, or on your PC?

2. Is the name of the file actually index.php?

3. Is there a live example?

 

Link to comment
Share on other sites

In you code you have an html error, The following tag is ended wrong:

<div id="text_about";

Notice the semi-colon at the end, this should be a less than sign (>), so the above line should be:

<div id="text_about">

 

Also the following line has a bug:

      if($new == $new2 && !$new2=''){

You use the assignment operator (=) rather than the comparison operator (==). Use the following instead:

      if($new == $new2 && !empty($new2)){

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.