Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,724 members, 7,816,977 topics. Date: Friday, 03 May 2024 at 09:56 PM

Please I Get This Error When Submit Form (notice: Undefined Index) - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Please I Get This Error When Submit Form (notice: Undefined Index) (1797 Views)

I Can't Solve This Error On My Php Page... / When You Get Error When Compiling Your Project How Do You Feel (2) (3) (4)

(1) (Reply) (Go Down)

Please I Get This Error When Submit Form (notice: Undefined Index) by nicolas247(m): 9:03am On Aug 31, 2016
Please some should help me look at my code

I am trying to fetch a set data from inside table . when ever i submit the require value, i get this error message

"Notice: Undefined index: memberId in C:\xamppp\htdocs\ibank\toinclude.php on line 8
No records matching your query were found."

Here is my code
<?php

$memberId = $_POST['memberId'];
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("localhost", "root", "", "ibank"wink;

// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}

// Attempt select query execution

$sql = "SELECT * FROM january WHERE memberId='$memberId'";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table>";
echo "<tr>";
echo "<th>date</th>";
echo "<th>description</th>";
echo "<th>credit</th>";
echo "<th>debit</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['credit'] . "</td>";
echo "<td>" . $row['debit'] . "</td>";
echo "</tr>";
}
echo "</table>";
// Close result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}

// Close connection
mysqli_close($link);

?>


Here is my form below


<!DOCTYPE html>
<!--
Template Name: Metronic - Responsive Admin Dashboard Template build with Twitter Bootstrap 3.3.4
Version: 3.3.0
Author: KeenThemes
Website: http://www.keenthemes.com/
Contact: support@keenthemes.com
Follow: www.twitter.com/keenthemes
Like: www.facebook.com/keenthemes
Purchase: http://themeforest.net/item/metronic-responsive-admin-dashboard-template/4021469?ref=keenthemes
License: You must have a valid license purchased only from themeforest(the above link) in order to legally use the theme for your project.
-->
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8"/>
<title>Metronic | Login Options - Login Form 1</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta content="" name="description"/>
<meta content="" name="author"/>
<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css"/>
<link href="assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/global/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN PAGE LEVEL STYLES -->
<link href="assets/admin/pages/css/login.css" rel="stylesheet" type="text/css"/>
<!-- END PAGE LEVEL SCRIPTS -->
<!-- BEGIN THEME STYLES -->
<link href="assets/global/css/components.css" id="style_components" rel="stylesheet" type="text/css"/>
<link href="assets/global/css/plugins.css" rel="stylesheet" type="text/css"/>
<link href="assets/admin/layout/css/layout.css" rel="stylesheet" type="text/css"/>
<link href="assets/admin/layout/css/themes/darkblue.css" rel="stylesheet" type="text/css" id="style_color"/>
<link href="assets/admin/layout/css/custom.css" rel="stylesheet" type="text/css"/>
<!-- END THEME STYLES -->
<link rel="shortcut icon" href="favicon.ico"/>
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="login">
<!-- BEGIN SIDEBAR TOGGLER BUTTON -->
<div class="menu-toggler sidebar-toggler">
</div>
<!-- END SIDEBAR TOGGLER BUTTON -->
<!-- BEGIN LOGO -->
<div class="logo">
<a href="index.html">
<img src="assets/admin/layout/img/logo-big.png" alt=""/>
</a>
</div>
<!-- END LOGO -->
<!-- BEGIN LOGIN -->
<div class="content">
<!-- BEGIN LOGIN FORM -->
<form class="login-form" action="form_processor.php?action=memberlogin" method="post">
<h3 class="form-title">Sign In</h3>
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
<span>
Enter any username and password. </span>
</div>
<div class="form-group">
<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
<label class="control-label visible-ie8 visible-ie9">Username</label>
<input class="form-control form-control-solid placeholder-no-fix" type="text" autocomplete="off" placeholder="Username" name="memberId"/>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Password</label>
<input class="form-control form-control-solid placeholder-no-fix" type="password" autocomplete="off" placeholder="Password" name="pwd"/>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-success uppercase">Login</button>
<label class="rememberme check">
<input type="checkbox" name="remember" value="1"/>Remember </label>
<a href="javascript:;" id="forget-password" class="forget-password">Forgot Password?</a>
</div>
<div class="login-options">
<h4>Or login with</h4>
<ul class="social-icons">
<li>
<a class="social-icon-color facebook" data-original-title="facebook" href="javascript:;"></a>
</li>
<li>
<a class="social-icon-color twitter" data-original-title="Twitter" href="javascript:;"></a>
</li>
<li>
<a class="social-icon-color googleplus" data-original-title="Goole Plus" href="javascript:;"></a>
</li>
<li>
<a class="social-icon-color linkedin" data-original-title="Linkedin" href="javascript:;"></a>
</li>
</ul>
</div>
<div class="create-account">
<p>
<a href="javascript:;" id="register-btn" class="uppercase">Create an account</a>
</p>
</div>
</form>
<!-- END LOGIN FORM -->
<!-- BEGIN FORGOT PASSWORD FORM -->
<form class="forget-form" action="index.html" method="post">
<h3>Forget Password ?</h3>
<p>
Enter your e-mail address below to reset your password.
</p>
<div class="form-group">
<input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="Email" name="email"/>
</div>
<div class="form-actions">
<button type="button" id="back-btn" class="btn btn-default">Back</button>
<button type="submit" class="btn btn-success uppercase pull-right">Submit</button>
</div>
</form>
<!-- END FORGOT PASSWORD FORM -->
<!-- BEGIN REGISTRATION FORM -->
<form class="register-form" action="form_processor.php?action=january" method="post">
<h3>Create an account</h3>
<p class="hint">
Enter your personal details below:
</p>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Username</label>
<input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="Username" name="memberId"/>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Password</label>
<input class="form-control placeholder-no-fix" type="password" autocomplete="off" id="register_password" placeholder="Password" name="pwd"/>
</div>

<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Full Name</label>
<input class="form-control placeholder-no-fix" type="text" placeholder="Name" name="fullname"/>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Sex</label>
<input class="form-control placeholder-no-fix" type="text" placeholder="Sex" name="sex"/>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Age</label>
<input class="form-control placeholder-no-fix" type="text" placeholder="Age" name="age"/>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Contact Address</label>
<input class="form-control placeholder-no-fix" type="text" placeholder="Contact Address" name="address"/>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">City/Town</label>
<input class="form-control placeholder-no-fix" type="text" placeholder="City/Town" name="city"/>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">State</label>
<input class="form-control placeholder-no-fix" type="text" placeholder="State" name="state"/>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Country</label>
<input class="form-control placeholder-no-fix" type="text" placeholder="Country" name="country"/>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Zip Code</label>
<input class="form-control placeholder-no-fix" type="text" placeholder="Zip Code" name="zipcode"/>
</div>
<div class="form-group">
<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
<label class="control-label visible-ie8 visible-ie9">E-mail</label>
<input class="form-control placeholder-no-fix" type="text" placeholder="Email" name="email"/>
</div>

<div class="form-group">
<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
<input class="form-control placeholder-no-fix" type="text" placeholder="vdvdv" name="secretNo"/>
</div>
<div class="form-group margin-top-20 margin-bottom-20">
<label class="check">
<input type="checkbox" name="tnc"/> I agree to the <a href="javascript:;">
Terms of Service </a>
& <a href="javascript:;">
Privacy Policy </a>
</label>
<div id="register_tnc_error">
</div>
</div>

<div class="form-actions">
<button type="button" id="register-back-btn" class="btn btn-default">Back</button>
<button type="submit" id="register-submit-btn" class="btn btn-success uppercase pull-right">Submit</button>
</div>
</form>
<!-- END REGISTRATION FORM -->
</div>
<div class="copyright">
2016 © All right Reserved.
</div>
<!-- END LOGIN -->
<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- BEGIN CORE PLUGINS -->
<!--[if lt IE 9]>
<script src="assets/global/plugins/respond.min.js"></script>
<script src="assets/global/plugins/excanvas.min.js"></script>
<![endif]-->
<script src="assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script src="assets/global/plugins/jquery-migrate.min.js" type="text/javascript"></script>
<script src="assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/global/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="assets/global/plugins/jquery.cokie.min.js" type="text/javascript"></script>
<script src="assets/global/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
<!-- END CORE PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script src="assets/global/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="assets/global/scripts/metronic.js" type="text/javascript"></script>
<script src="assets/admin/layout/scripts/layout.js" type="text/javascript"></script>
<script src="assets/admin/layout/scripts/demo.js" type="text/javascript"></script>
<script src="assets/admin/pages/scripts/login.js" type="text/javascript"></script>
<!-- END PAGE LEVEL SCRIPTS -->
<script>
jQuery(document).ready(function() {
Metronic.init(); // init metronic core components
Layout.init(); // init current layout
Login.init();
Demo.init();
});
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>
Re: Please I Get This Error When Submit Form (notice: Undefined Index) by nicolas247(m): 10:22am On Aug 31, 2016
Why is everyone just looking and pass
Re: Please I Get This Error When Submit Form (notice: Undefined Index) by lekropasky(m): 11:15am On Aug 31, 2016
Maybe i miss it, but i cant see your form where you specify the action to be toinclude.php, try and check your form post paramters very well, the problem is there.
Re: Please I Get This Error When Submit Form (notice: Undefined Index) by FincoApps(m): 4:14pm On Aug 31, 2016
Your form action is index.html.

Change it to the location of your php
Re: Please I Get This Error When Submit Form (notice: Undefined Index) by nicolas247(m): 7:41pm On Aug 31, 2016
lekropasky:
Maybe i miss it, but i cant see your form where you specify the action to be toinclude.php, try and check your form post paramters very well, the problem is there.

Thanks for you contribution

here is cut out of the form to submit

<!-- BEGIN LOGIN FORM -->
<form class="login-form" action="form_processor.php?action=memberlogin" method="post">
<h3 class="form-title">Sign In</h3>
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
<span>
Enter any username and password. </span>
</div>
<div class="form-group">
<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
<label class="control-label visible-ie8 visible-ie9">Username</label>
<input class="form-control form-control-solid placeholder-no-fix" type="text" autocomplete="off" placeholder="Username" name="memberId"/>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Password</label>
<input class="form-control form-control-solid placeholder-no-fix" type="password" autocomplete="off" placeholder="Password" name="pwd"/>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-success uppercase">Login</button>
Re: Please I Get This Error When Submit Form (notice: Undefined Index) by nicolas247(m): 7:42pm On Aug 31, 2016
FincoApps:
Your form action is index.html.

Change it to the location of your php

Here is the where the action pointing to

<form class="login-form" action="form_processor.php?action=memberlogin" method="post">
Re: Please I Get This Error When Submit Form (notice: Undefined Index) by CodeHouse: 8:25pm On Aug 31, 2016
Post your codes clearly, let's see the line 8
Re: Please I Get This Error When Submit Form (notice: Undefined Index) by lekropasky(m): 9:28pm On Aug 31, 2016
nicolas247:


Thanks for you contribution

here is cut out of the form to submit

<!-- BEGIN LOGIN FORM -->
<form class="login-form" action="form_processor.php?action=memberlogin" method="post">
<h3 class="form-title">Sign In</h3>
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
<span>
Enter any username and password. </span>
</div>
<div class="form-group">
<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
<label class="control-label visible-ie8 visible-ie9">Username</label>
<input class="form-control form-control-solid placeholder-no-fix" type="text" autocomplete="off" placeholder="Username" name="memberId"/>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Password</label>
<input class="form-control form-control-solid placeholder-no-fix" type="password" autocomplete="off" placeholder="Password" name="pwd"/>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-success uppercase">Login</button>
. Are you sure you are catching the POST parameters in form_processors.php? You form action should be toinclude.php
Re: Please I Get This Error When Submit Form (notice: Undefined Index) by talk2hb1(m): 9:09pm On Sep 01, 2016
Try runnibg the query in phpmyadmin, use the code to run your query. That should work wink
Re: Please I Get This Error When Submit Form (notice: Undefined Index) by FrankLampard: 10:27pm On Sep 02, 2016
If I understand you correctly, you are trying to assign a variable without initializing the variable to something, before using it.

One way to remove this error. Is to first initialize the variable to something, then set it to you $_POST variable.


$memberId = "";

$memberId = $_POST['memberId'];

OR just assigning your variable using the isset() method

$memberId = isset($_POST['memberId']);

Your error should go away.

Read this, it may help.

http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index

I didn't go through the link sha, but the title explains the error.

Thank you.
Re: Please I Get This Error When Submit Form (notice: Undefined Index) by lekropasky(m): 6:26am On Sep 03, 2016
$memberId = isset($_POST['memberId']) ;
Return a boolean value i guess.
Re: Please I Get This Error When Submit Form (notice: Undefined Index) by FrankLampard: 6:57am On Sep 03, 2016
isset() method or function return TRUE, when a value is set, and FALSE when a value is unset.
Re: Please I Get This Error When Submit Form (notice: Undefined Index) by foldl: 9:13am On Sep 03, 2016
nicolas247:
Why is everyone just looking and pass

Because they can't read your code! Always use tools like hastebin.com or github gists when you want to share snippets of code. I don't want to strain my eyes reading through lengthy code without the benefit of proper syntax highlighting just because I want to be helpful.

2 Likes

Re: Please I Get This Error When Submit Form (notice: Undefined Index) by nicolas247(m): 10:21am On Sep 23, 2016
foldl:


Because they can't read your code! Always use tools like hastebin.com or github gists when you want to share snippets of code. I don't want to strain my eyes reading through lengthy code without the benefit of proper syntax highlighting just because I want to be helpful.

note
thanks the problem was solved

i will share the solution soon thanks

(1) (Reply)

How To Code This Logic With Php... / Learn And Develop Real Life Web Applications In 11 Weeks / How To Activate Mtn 75mb Data With #20

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 77
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.