473,396 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

want to acess array value in $_post variable from newreg.php to validate.php this

newreg.php

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. include 'validate.php';
  3. include 'connection.php';
  4. include 'formclass.php';
  5. ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Register Here...</title> <style type="text/css">
  6. .table {
  7.     width: auto;
  8.     margin-top: 100px;
  9. }
  10.  
  11. .body {
  12.     background-image:url("http://bytes.com/images/background.jpeg"); background-repeat: repeat-x;background-repeat: repeat-y;
  13. }
  14. .errorMsg{border:1px solid red; }
  15. </style> </head> <body class="body"> <fieldset style="margin-left: 500px; margin-right: 500px; margin-top: 90px"> <legend><img src="http://bytes.com/images/reg.jpg" width="150px"></legend> <table align="center" class="table"> <?=$error?> <?php 
  16. $form = new Form();
  17. echo $form->create(array('id'=>'registration','name'=>'registration','method'=>'post','action'=>'newreg.php'));
  18. ?>  <tr> <td><?php $label= new form;
  19. echo $label->label1(). "Username";
  20.  
  21. ?> </td> <td>  <?php $textbox= new form;
  22.  $par = array(
  23.          array(
  24.                  'name'=>'name11',
  25.                  'value'=>$username,
  26.                  'id'=>'name',
  27.                 'maxlength'=>'50'
  28.  
  29.          ));
  30.  
  31.  echo $textbox->text($par);
  32.  
  33.  
  34. ?> </td> <td><?=$error1?> </td> </tr> <tr><td>
  35. Email   :</td><td><input type="text" name="email" value="<?=@$email ?>" maxlength="100" /></td><td> </td></tr> <tr><td>
  36. password:</td><td><input type="password" name="password" value="<?=@$password?>" maxlength="32"/></td><td></td></tr> <tr><td>
  37. Re-password:</td><td><input type="password" name="repassword" value="<?=@$password1?>" maxlength="32"/></td><td></td></tr> <tr><td></td><td><input type="submit" name="submit" value="Submit"/></td><td></td> </tr> </FIELDSET> </table>  <?php echo $form->close(); ?> <?php
  38.            // if (isset($_POST['submit']) && $error == '') { // if there is no error, then process further
  39.             //   echo "<p class='success'>Form has been submitted successfully.</p>"; // showing success message
  40.  
  41.                 // hashing the password and sanitize data
  42.              // $_POST['password'] = md5($_POST['password']);
  43.               // foreach ($_POST as $key => $val) {
  44.                 //  $_POST[$key] = mysql_real_escape_string($_POST[$key]);
  45.                     // Or you can use $mysqli->real_escape_string() as above function is deprecated
  46.                     // Or you can use prepared statements to sanitize
  47.                     // Use stripslashes to do the opposite
  48.               //  }
  49.  
  50.  
  51.                 // do stuffs with validated & safe data
  52.  
  53.                 //show the raw data (for practice)
  54.               //  var_dump($_POST);
  55.            // }
  56.         ?> </body> </html>
  57.  
  58. this is my textbox and label construct by using opps class concept
  59. these all values are stored in $par variable
  60.  
  61. i want to fetch name value for validation from this array and want to use with $_post[] command
  62.  
  63.  
  64. validate.php
  65.  
  66.  
  67. <?php 
  68. include 'connection.php';
  69. $error = ""; // Initialize error as blank
  70. $error1 = ""; 
  71.  
  72. //$username=$_POST['name'];
  73. //$email=$_POST['email'];
  74. //$password=$_POST['password'];
  75. //$password1=$_POST['repassword'];
  76. if (isset($_POST['submit'])) 
  77. { // check if the form is submitted
  78.     #### removing extra white spaces & escaping harmful characters ####
  79.    // $username= trim($_POST['name']);
  80.     $password= trim($_POST['password']);
  81.     $password1= trim($_POST['repassword']);
  82.     $email= trim($_POST['email']);
  83.            if ($username=="") {
  84.         $error1 .= '<p class="error">Username should not be empty</p>';
  85.     }
  86.     // if username is not 3-20 characters long, throw error
  87.    /* if (strlen($username) >= 20) {
  88.         $error .= '<p class="error">Username should be less than 20 character</p>';
  89.     }
  90.     if (ctype_digit($username)) {
  91.         $error1 .= '<p class="error">Username should not accept number</p>';
  92.     }*/
  93.     if (!ctype_alpha($username)) {
  94.         $error .= '<p class="error">Username should accepts only alphabets</p>';
  95.     }
  96.   /* if ($password1 != $password) {
  97.         $error .= '<p class="error"Password not match</p>';
  98.     }*/
  99.  
  100. if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) {
  101.   $error .= "Invalid email format"; 
  102. }
  103. else if (isset($_POST['submit']) && $error == '') { // if there is no error, then process further
  104.                //echo "<p class='success'>Form has been submitted successfully.</p>"; // showing success message
  105.                $sql= "insert into reg(name, email, password, repassword,status) Values('". $_POST['name']."', '". $_POST['email']."', '". $_POST['password']."', '". $_POST['repassword']."', '1')";
  106.                $result= mysqli_query($con, $sql);
  107.               if (!$result){
  108.                   echo "not connected to database";
  109.               }
  110.               else {
  111.                   echo "data entered sucessfully";
  112.               }
  113. }
  114.     mysqli_close($con);
  115. }
  116.  
  117.     ?>
May 12 '14 #1
1 1535
Dormilich
8,658 Expert Mod 8TB
is there a problem?
May 13 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Phil Powell | last post by:
$successMsgArray = array('image' => array('add_album' => 'Album: "$album" has been created', 'edit_album' => 'Information for album "$album" has been changed')); I am having to return the...
3
by: Thomas Hoheneder | last post by:
Hello, I use PHP 4.3.10 and want to deliver a post variable from a PHP page to itself. In my page mypage.php I have a hidden field named "dbaction" and a form button. When clicking the form...
8
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when...
7
by: hpy_awad | last post by:
I need to make the size of an array as variable read from screen . How can I do it ?
1
by: JAG | last post by:
I am getting an error using the replace method in one of my functions. I am using the replace method in the mail document function in my frameset .hta to change forward slashes to back slashes in...
4
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on...
4
by: toadstool | last post by:
I have an array containing the various products $inventory = array(); $inventory = "whatever1"; etc I have an array containing various values $quantity = array(100,200,300); I call in a...
11
by: Tyler Harder | last post by:
Hello, I'm having some trouble creating a dynamic variable that will load an array value: $this_content_json When I use the above line 'hard coded', it works. But when I use the code below as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.