Jump to content

Pushing data to other file


ShadowAS1

Recommended Posts

Hi,

I've created an login/registration system (not the one i talked about before, thisone was written by myselves)

Now when the user submits the form on page a it gets sent to profile.php?do=login (because profile.php handles multiple things)

Now i've got errors that happen all pushed into $aErrorAray This can be one or multiple errors. Now how can I get that posted back to index.php? when submitting from index.php to profile.php i used the form submit function but as far as i understand that doenst apply here

 

Thanks

ShadowAS1

Link to comment
https://forums.phpfreaks.com/topic/241904-pushing-data-to-other-file/
Share on other sites

If you mean how do you get the error array from profile.php if profile.php redirects to index.php?  Then I say put the error array in the session and retrieve it on index.php.

 

http://us2.php.net/manual/en/book.session.php

Yes it worked, partially

Before you link me to the articles.. i read them already cause it was told me before but in this case they don't work out.. i get the famous header already sent

Checked the document its UTF-8 Without BOM, no space before PHP tag anyways, my code

 

error occured at line 79 that piece of PHP was exactly what i was testing ATM. it gives me the output off err1 as it's ment to do but before it does it gives the error

 

<?php
if ($_GET['do'] == error) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Project: </title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<link href="script/style.css" rel="stylesheet" type="text/css" />
<!--[if lt IE 7]><link href="script/ie.css" rel="stylesheet" type="text/css" /><![endif]-->
<!--[if IE 7]><link href="script/ie7.css" rel="stylesheet" type="text/css" /><![endif]-->
</head>
<body>
<div id="wrapper">
    	<div id="header">
        	<p><span>rev.:</span> <strong>0.5B1</strong></p>
            	<ul>
                	<li class="no_bg"><a href="#">home</a></li>
                    <li><a href="#">FAQ</a></li>
                    <li><a href="#">help</a></li>
                    <li><a href="#">contact</a></li>
        		</ul>
        </div> <!--header ends-->
        
        <a href="#" id="logo" title="CommunicatiePaspoort" class="replace"><span>CommunicatiePaspoort</span></a>
        
        <!--<form id="search_form" action="search">
        	<p><input type="text" value="Search this site for..." />
            	<input type="submit" id="submit" value="" /></p>
        </form> <!--form ends-->
        
       <!-- <div id="banner">
        	<img src="images/banner.jpg" alt="" />
        </div> <!--banner ends-->
        
        <div id="navigation">
        	<ul>
            	<li class="active"><a href="#">Home</a></li>
                <li><a href="#">OVER</a></li>
                <li><a href="#">LOGIN</a></li>
                <li><a href="#">REGISTREER</a></li>
                <li><a href="#">HELP</a></li>
                <li><a href="#">FAQS</a></li>
                <li><a href="#">Contact </a></li>
        	</ul>
        </div> <!--navigation ends-->
        
        <div id="content">
        	<div id="left_column">
            	<div class="text">
                	<h2>Welkom</h2>
                    	<p>Beschrijving....</p>
            	</div> <!--text ends-->
                
                <div class="text alternative">
                	<h2>EVT. 2e Tekst</h2>
                    	<p>Beschrijving</p>
                </div> <!--text ends-->
                
                <div class="text">
                	<h2>EVT. 3e Tekst</h2>
                    	<p>Beschrijving</p>
                </div> <!--text ends-->
            </div> <!--left column ends-->
            
            <div id="right_column">
              <div class="heading">
                <h2>Login:</h2>
          </div> <!--heading ends-->
           	  <ul>
                	 <form action="profile.php?do=login" method="post"> 
                    <li><input type="text" name="username" value="Gebruikersnaam." /></li>
           	    <li><input type="password" name="pass" value="Wachtwoord." /></li>
                    <li><input type="submit" name="submit" id="submit" value="Login" /></li>
				<li></strong>De volgende fouten zijn opgetreden</strong></li>
<?php
				session_start();
				echo("<li>".$_SESSION['err1']."</li>\r\n");
				echo($_SESSION['err2']."\r\n");
				echo($_SESSION['err3']."\r\n");
				echo($_SESSION['err4']."\r\n");
				echo($_SESSION['err5']."\r\n");
				session_destroy();//session moet destroyed worden zodat de gebruiker normaal kan inloggen
?>
                  </form>
                <li>

                </li>
       	      </ul>
                
                <div class="heading">
               	  <h2>Koptekst 1</h2>
              </div> <!--heading ends-->
                	<ul>
            			<li><span>Mogelijke</span> invulling</li>
            		</ul>
                
                <div class="heading">
                	<h2>Koptekst 2</h2>
                    	<img src="images/comments_icon.jpg" alt="" />
                </div> <!--heading ends-->
                	<ul>
            			<li><span>Mogelijke</span> invulling</li>

            		</ul>
            </div> <!--right column ends-->
        </div> <!--content ends-->
</div> <!--wrapper ends-->
    
    <div id="footer">
    	<div id="footer_content">
        	<ul>
        		<li class="no_bg"><a href="#">home</a></li>
                <li><a href="#">FAQ</a></li>
                <li><a href="#">help</a></li>
                <li><a href="#">contact</a></li>
		</ul>
            <p> © 2011 ShadowAS1.com.   All Rights Reserved</p>
    	</div> <!--footer content ends-->
    </div> <!--footer ends-->
</body>
</html>
<?php
}else{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Project: </title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<link href="script/style.css" rel="stylesheet" type="text/css" />
<!--[if lt IE 7]><link href="script/ie.css" rel="stylesheet" type="text/css" /><![endif]-->
<!--[if IE 7]><link href="script/ie7.css" rel="stylesheet" type="text/css" /><![endif]-->
</head>
<body>
<div id="wrapper">
    	<div id="header">
        	<p><span>rev.:</span> <strong>0.5B1</strong></p>
            	<ul>
                	<li class="no_bg"><a href="#">home</a></li>
                    <li><a href="#">FAQ</a></li>
                    <li><a href="#">help</a></li>
                    <li><a href="#">contact</a></li>
        		</ul>
        </div> <!--header ends-->
        
        <a href="#" id="logo" title="CommunicatiePaspoort" class="replace"><span>CommunicatiePaspoort</span></a>
        
        <!--<form id="search_form" action="search">
        	<p><input type="text" value="Search this site for..." />
            	<input type="submit" id="submit" value="" /></p>
        </form> <!--form ends-->
        
       <!-- <div id="banner">
        	<img src="images/banner.jpg" alt="" />
        </div> <!--banner ends-->
        
        <div id="navigation">
        	<ul>
            	<li class="active"><a href="#">Home</a></li>
                <li><a href="#">OVER</a></li>
                <li><a href="#">LOGIN</a></li>
                <li><a href="#">REGISTREER</a></li>
                <li><a href="#">HELP</a></li>
                <li><a href="#">FAQS</a></li>
                <li><a href="#">Contact </a></li>
        	</ul>
        </div> <!--navigation ends-->
        
        <div id="content">
        	<div id="left_column">
            	<div class="text">
                	<h2>Welkom</h2>
                    	<p>Beschrijving....</p>
            	</div> <!--text ends-->
                
                <div class="text alternative">
                	<h2>EVT. 2e Tekst</h2>
                    	<p>Beschrijving</p>
                </div> <!--text ends-->
                
                <div class="text">
                	<h2>EVT. 3e Tekst</h2>
                    	<p>Beschrijving</p>
                </div> <!--text ends-->
            </div> <!--left column ends-->
            
            <div id="right_column">
              <div class="heading">
                <h2>Login:</h2>
          </div> <!--heading ends-->
           	  <ul>
                	 <form onsubmit="emptyForm();" action="profile.php?do=login" method="post"> 
                    <li><input type="text" name="username" value="Gebruikersnaam." /></li>
           	    <li><input type="password" name="pass" value="Wachtwoord." /></li>
                    <li><input type="submit" name="submit" id="submit" value="Login" /></li>
                  </form>
                <li>

                </li>
       	      </ul>
                
                <div class="heading">
               	  <h2>Koptekst 1</h2>
              </div> <!--heading ends-->
                	<ul>
            			<li><span>Mogelijke</span> invulling</li>
            		</ul>
                
                <div class="heading">
                	<h2>Koptekst 2</h2>
                    	<img src="images/comments_icon.jpg" alt="" />
                </div> <!--heading ends-->
                	<ul>
            			<li><span>Mogelijke</span> invulling</li>

            		</ul>
            </div> <!--right column ends-->
        </div> <!--content ends-->
</div> <!--wrapper ends-->
    
    <div id="footer">
    	<div id="footer_content">
        	<ul>
        		<li class="no_bg"><a href="#">home</a></li>
                <li><a href="#">FAQ</a></li>
                <li><a href="#">help</a></li>
                <li><a href="#">contact</a></li>
		</ul>
            <p> © 2011 ShadowAS1.com.   All Rights Reserved</p>
    	</div> <!--footer content ends-->
    </div> <!--footer ends-->
</body>
</html>
<?php
}
?>

ah ok got that.. now i push the array in a value in my cas $_SESSION['errortable']

 

in index.php I did put session_start(); at the top

 

and to collect the errors I did:

foreach ($_SESSION['errortable'] as $sError) {
echo "<li>* $sError</li>\n";
}

i've tried putting $aErrorArray = $_SESSION['errortable']; but that wouldn't work

 

the error i'm getting

 

Warning: Invalid argument supplied for foreach() in /home/httpdaemon/domains/centos.lan/public_html/passport/index.php on line 86

 

Line 86: foreach ($_SESSION['errortable'] as $sError) {

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.