Header status showing 404 error. How to fix? - php

I have made login pages outside the wordpress theme folder. The code is running perfectly but there are some errors showing.
Header status showing 404 instead 200.
Body has class error404.
Title is not rendering correctly. I solved it by coding the static javascript line.
Here is my page outside the WP-Theme:
<?php include './Logincheck.php'; require( '../wp-blog-header.php'); ?>
<script>
document.title = "Login - Peerless Institute";
</script>
<?php require( './wp-config.php'); ?>
<div class="main-title">
<div class="container">
<h1 class="main-title__primary">Login</h1>
</div>
</div>
<div class="master-container">
<div class="container page type-page" role="main">
<div id="content">
<div class="login-content">
<form action="" method="post">
<?php echo $ErrorMsg ;?>
<input type="password" maxlength="100" name="passcode" placeholder="Enter Passcode:" />
<input type="submit" value="Go" class="btn btn-primary" />
</form>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
How to fix this issue ? Please help me out of here.

Some of my developer made rule in .htaccess. I changed it according to my terms. It solved.
Thank you for time and consideration.

Related

Hide Form Div Using PHP if Statment

Trying to make a login form become hidden once a successful login has happened within the form, so that the form cannot be seen by the user once they are logged in, but I still need a success message to be displayed when a successful login has happened.
I have the form and the login sorted and it displayed a success message when a successful login has been made but I cant hide the form upon successful login.
i have an if statement set up using isset but that's as far as I got I don't know what needs to go inside the if statement for me to hide the form.
This is the PHP code for my login page -
<?php
require('includes/application_top.php');
$page_title='Login!';
if (isset($_POST['action'])) {
$username_input = $_POST['username'];
$password_input = $_POST['password'];
$login_ok = login($username_input, $password_input);
}
require('includes/site_header.php');
?>
<style>
<?php
require('css/login.css');
?>
</style>
<br>
<br>
<br>
<?php
if (isset($login_ok)) {
?>
<div class="row">
<div class="col-sm-12">
<?php
if ( ! $login_ok) {
?>
<div class="alert alert-danger">
<p>Your credentials were invalid</p>
</div>
<?php
} else {
?>
<div class="alert alert-success">
<p>Login successful</p>
</div>
<?php
}
?>
</div>
</div>
<?php
}
?>
<!-- This is the if statement I mention -->
<?php
if !isset($login_okay){
?>
<div class="wrapper dafswInDown" hidden>
}
?>
<div class="wrapper fadeInDown">
<div id="formContent">
<!-- Icon -->
<div class="fadeIn first">
<br>
<img src="images/Head1.jpg" style="height: 40%; width: 60%;" id="icon" alt="User Icon" />
<br>
<h3> Login! </h3>
</div>
<br>
<!-- Login Form -->
<form id="login_form" action="login_page.php" method="post">
<input type="text" class="fadeIn second" id="username" name="username" placeholder="Username" value="<?= isset($_POST['username']) ? htmlspecialchars($_POST['username']) : '' ?>" maxlength="100" />
<input type="password" class="form-control" id="password" name="password" placeholder="Password" value="" />
<input type="submit" class="fadeIn fourth" name="action" value="Login"/>
</form>
<!-- Remind Passowrd -->
<div id="formFooter">
<a class="underlineHover" href="#">Forgot Password?</a>
</div>
</div>
</div>
<?php
require('includes/application_bottom.php');
require('includes/site_footer.php');
?>
There are a number of different ways you can approach this problem, but i think the best way to do this is with a session variable. Make your login function create a session variable that will follow the logged in user around throughout the website, then its just a matter of checking for the value and either displaying or hiding the form based on that. Here is a simplified example:
<?php function login($username_input=false, $password_input=false){
// Do all your verification here
// If logged in then:
session_start();
$_SESSION["user"] = true;
}
// Then on the form side just do this:
if(!$_SESSION["user"]){ ?>
FORM HERE
<?php } ?>

Joomla custom form action doesn't work

I'm learning how to make my own module on Joomla.
MyModule mod_planejamentomensal.php is like this:
//No direct access
defined('_JEXEC') or die;
require_once dirname(__FILE__) . '/helper.php';
Jhtml::_('jquery.framework');
Jhtml::_('jquery.ui');
JHtml::_('behavior.formvalidator');
JHtml::script(JURI::base() . '/modules/mod_planejamentomensal/js/jquery-3.3.1.js');
JHtml::script(JURI::base() . '/modules/mod_planejamentomensal/js/jquery.mask.js');
default.php has my form (with some other fields and jQuery, I'm copying part of it here so it won't be too long):
<div class="planj-mensal-form">
<form method="post" name="frmCasdastra" class="form-validate" action="<?php JURI::base() . '/modules/mod_planejamentomensal/tmpl/adicionaForm.php' ?>">
<div class="divTable">
<div class="divTableRow">
<div class="divTableColumn">
<b>Solicitação nº:</b> <?php //echo $solicitacaoTemp; ?>
</div>
</div>
<div class="divTableRow">
<div class="divTableColumn divTableColumn1">
<b>Agência:</b> <?php echo $grupo; ?>
</div>
<div class="divTableColumn divTableColumn2">
<div class="divLabel"><label for="mes">Mês Referência:</label></div>
<div class="divInput">
<select name="mes">
<?php
$select = $planMensal->setSelect($mes, 'mes', date('m',strtotime('+1 month')));
echo $select;
?>
</select>
</div>
</div>
</div>
<div class="divTableRow">
<div class="divtableColumnBotao">
<div class="divInput">
<input name="add" type="button" value="Adicionar mais um formulário" id="add">
</div>
</div>
</div>
</div>
</form>
</div>
So, my form action above points to adicionaForm.php which is like:
<?php
defined('_JEXEC') or die;
$input = new JInput;
$teste = $input->get('mes',null);
echo "Show: "+$teste;
?>
But when I click on submit button nothing happens...I Know there must be something on Joomla that I'm doing wrong. I tried to read documentation for forms but I didn't understand much of it. Can anyone please give me a hint?
Ok, at first I thought my action address was somehow wrong. But I got the answer from another site and figure this out: my code wasn't working because of the button's input type.
So I changed it from:
<input name="add" type="button" value="Adicionar mais um formulário" id="add">
To:
<input name="add" type="submit" value="Adicionar mais um formulário" id="add">
And it worked just fine.

$_POST not working when JQuery is included

So, I'm having an issue where my $_POST variable does not work whenever I have JQuery included on the page.
If I comment out the JQuery link it works fine. I have asked a similar question before, but did not get a full answer and have used a workaround which does not work with this page.
My full code is as followed:
<?php
if(isset($_POST['home-register-submit']))
{
echo '<script>alert("Works!");</script>';
}
?>
<div id='home-register'>
<div id='home-register-title'><h4>Aanmelden</h4></div>
<hr>
<form method="POST">
<label>Voornaam:</label> <div id='home-register-input'><input type="text" name='home-register-fname'></div><br />
<label>Achternaam:</label> <div id='home-register-input'><input type='text' name='home-register-lname'></div><br />
<label>Leeftijd:</label> <div id='home-register-input'><input type='' name='home-register-age'></div><br />
<label>Telefoon:</label> <div id='home-register-input'><input type='tel' name='home-register-phone'></div><br />
<label>Email:</label> <div id='home-register-input'><input type='email' name='home-register-email'></div><br />
<button class="btn btn-default btn-sm" type='submit' name='home-register-submit'>Versturen</button>
</form>
</div>
<!-- jQuery -->
<script src="js/jquery.js"></script>
Fixed it by excluding a file called clean-blog.min.js which apparently blocked my page from using $_POST.

How to redirect signup page after successfull registration in wordpress without plugin

1.This is my signup page. This page redirect to http://mysite.com/wp-login.php?checkemail=registered.. i want to go to custom page.. please help me
<?php
/**
* Template Name: Sign-up
*/
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<h2><strong>Sign up</strong></h2>
<form action="<?php echo site_url('wp-login.php?action=register', 'login') ?>" class="user_new" id="user_new" method="post">
<p> <input id="user_login" name="user_login" size="30" type="text" placeholder="Select a username"></p>
<p> <input id="user_email" name="user_email" size="30" type="text" placeholder="Email address"></p>
<?php do_action('register_form'); ?>
<input id="register" type="submit" value="Sign up">
</form>
<p>A password will be emailed to you</p>
<p>Already a user? <a href="/login/" >Login</a>!</p>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
The following plugin will help you solve this problem.
http://wordpress.org/plugins/rename-wp-login/
In the Settings permalink you can manage the URL for login page and this will act as redirect rule for all wp admin pages.

Implementing a user level access in my site?

I need to know how can I implement a user level access in my site. I need to hide forms and images when users with level are member...
in my DB I have a USERS TABLE with:
id
nombre
apellido
username
password
level
level is ENUM and have this two selects: administrator and member
I can hide scripts in any page with this type of PHP code:
<?php if(basename($_SERVER['PHP_SELF']) == 'contact.php') { ?>
<script src="js/jquery.js"></script>
<?php } ?>
and works very well, but I don't know how can hide per example this:
<div class="box span6">
<div class="box-header well" data-original-title>
<h2><i class="icon-picture"></i> <?php $translate->__('Save images'); ?></h2>
<div class="box-icon">
<i class="icon-chevron-up"></i>
<i class="icon-remove"></i>
</div>
</div>
<div class="box-content">
<form action="upload.php" method="post" name="image_upload" id="image_upload" enctype="multipart/form-data">
<label><?php $translate->__('Images type'); ?> (gif, jpg, png)</label><br />
<input type="file" size="45" name="uploadfile" id="uploadfile" class="file margin_5_0" onchange="ajaxUpload(this.form);" />
<div id="upload_area" class="corners align_center">
<?php $translate->__('Please select one image'); ?>.
</div>
</form>
</div>
</div>
In google I saw this code but don't work in my partycular case:
<?php if($USERS->level == "administrator"): ?>
<?php endif; ?>
can you help me with my problem?
Hiding js files will not do you much good because an attacker can intercept the javascript file being served to your admin user, build his own mock-up page of your site and have it use that javascript. So make sure to put security and validation in your php code, especially inside your upload.php
Obviously this $USERS->level can be replaced by any variable that you have set.
<?php if($USERS->level == "administrator")
{
?>
<div class="box span6">
<div class="box-header well" data-original-title>
<h2><i class="icon-picture"></i> <?php $translate->__('Save images'); ?></h2>
<div class="box-icon">
<i class="icon-chevron-up"></i>
<i class="icon-remove"></i>
</div>
</div>
<div class="box-content">
<form action="upload.php" method="post" name="image_upload" id="image_upload" enctype="multipart/form-data">
<label><?php $translate->__('Images type'); ?> (gif, jpg, png)</label><br />
<input type="file" size="45" name="uploadfile" id="uploadfile" class="file margin_5_0" onchange="ajaxUpload(this.form);" />
<div id="upload_area" class="corners align_center">
<?php $translate->__('Please select one image'); ?>.
</div>
</form>
</div>
</div>
<?php
}
?>

Categories