Jump to content

meomike2000

Members
  • Posts

    171
  • Joined

  • Last visited

    Never

Posts posted by meomike2000

  1. well here is what i got...

     

    it works, uploads photos, stores them in a directory on disk, wish i didnt have to save them to the disk, stores the information about the photo in database.

     

    //open database
    //retrieve form data. 
    $tag = $_POST['tag'];
    $target = "images/";
    $target = $target . basename( $_FILES['imagefile']['name']); 
    //$img = ($_FILES['imagefile']['name']);
    $img = $target;
    
    if (move_uploaded_file($_FILES['imagefile']['tmp_name'], $target))
    //}
    $filesize = ($_FILES['imagefile']['size']);
    $filename = ($_FILES['imagefile']['name']);
    $filetype = ($_FILES['imagefile']['type']);
    
    if ($filetype = 'image/jpeg')
    {
    if ($filesize < 1000000)
    {
               //here i query the database and insert info.. then close connection, return to     upload page.... done....
             }
    }
    

     

    i can call the photos up to view like this

     

    //open database and query
    // process results here
    if(mysql_num_rows($resultimg) == 0)
    {
       echo "upload some photos <br>";
    }
    else
    {
    	while ($row = mysql_fetch_row($resultimg))
      {
      	echo "<br> filename='".$row[2]."'<br> ";
       	        echo "Content-tag: '".$row[1]."'<br>";
       	        echo "Content-length: '".$row[3]."'<br>";
       	        echo '<img class="images" src="/the path to photos/'.$row[0].'"  
                    width=75px  height=75px><br>';
             }
    }
    

  2. that stores them well but how do i view them now.

     

    i tried this style... all i get is encrypted data again.....

     

    
    $query  = "SELECT content, phtag, phname FROM uphotos where fk_uid = '" . $userid . "'";
    $resultph = mysqli_query($query) or die('Error, query failed');
    
    if(mysql_num_rows($resultph) == 0)
    {
       echo "upload some photos <br>";
    }
    else
    {
    while ($row = mysql_fetch_row($resultph))
       {
        echo '<img src="'.$row[0].'"><br>' . $row[1] . ' &nbsp ' . $row[3] . '<br><br><br>';   
       }
    }
    

     

    like i said this is my first try at image uploads......

  3. ok this is what i got and it works somewhat.

     

    <?php
    $target = "images/";
    $target = $target . basename( $_FILES['imagefile']['name']); 
    $img = ($_FILES['imagefile']['name']);
    
    //then i update the database.
    
    //then i
    
    move_uploaded_file($_FILES['imagefile']['tmp_name'], $target);
    
    //then script carries on.
    ?>
    

     

    can anybody help me set this so that only images get uploaded, and preferrable less than 1mb or less if there is a way to make the photos require less.......

     

    thanks in advance mike.....

  4. ok i have worked out some of the problem...

     

    changed code to

    $uploaddir = "images"; 
    //if(move_uploaded_file($_FILES['imagefile']['tmp_name'],$uploaddir $_FILES['imagefilefile']['name']))
    //{
    if (move_uploaded_file($_FILES['imagefile']['tmp_name'],"images/latest.img"))
    {
            $instr = fopen("images/latest.img","rb");
            $image = addslashes(fread($instr,filesize("images/latest.img")));
    
    $img = $image;
    
      }
    else
      {
      $img = null;
      }
    

     

    and the file uploads and is stored in the database.....

     

    problem now is when i try to view the image, all i get is encrypted data on the screen....

    please please help...... mike

  5. when set this way:

     

    $uploaddir = "images"; 
    //if(move_uploaded_file($_FILES['imagefile']['tmp_name'],$uploaddir $_FILES['imagefilefile']['name']))
    //{
    if (move_uploaded_file($_FILES['imagefile']['tmp_name'],"latest.img"))
    {
            $instr = fopen("latest.img","rb");
            $image = addslashes(fread($instr,filesize("latest.img")));
    
    echo "Your file has been uploaded successfully! Yay!";
    
      }
    else
      {
      $img = "Invalid file";
      }
    
    i get this:
    
    Warning: move_uploaded_file(latest.img) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/mike/web/home/editit.php on line 14
    
    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php1gY3lh' to 'latest.img' in /home/mike/web/home/editit.php on line 14
    

  6. have changed the code to :

     

    $uploaddir = "images";

    if(move_uploaded_file($_FILES['imagefile']['tmp_name'],$_FILES['imagefilefile']['name']))

    {

     

     

    echo "Your file has been uploaded successfully! Yay!";

     

      }

    else

      {

      $img = "Invalid file";

      }

     

     

    now i get this error:

     

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpuG1bTf' to '' in /home/mike/web/home/editit.php on line 12

     

    help please.......

  7. tried that way aswell,  still no luck, starting to think that it is a permissions issue.

     

    not real sure on the $uploaddir = "images";  folder, i mean were would this folder be, i assume that it would be in the same directory as the script. is that wrong......

     

    please i really need some help here.......

     

    thanks in advance mike.

  8. i have been trying to create an image upload so that users can upload an image and then store that image in the datebase.

     

    i have read many how to s on this and i am still having trouble.

    this is the code that i got.

     

    $uploaddir = "images"; 
    if(is_uploaded_file($_FILES['file']['tmp_name']))
    
    {
    
    move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
    
    
    
    echo "Your file has been uploaded successfully! Yay!";
    
      }
    else
      {
      $img = "Invalid file";
      }
    

     

    the end result for me is always invalid file.

     

    i am a little confused on the basedir. is that starting at the dir. that the script is in or what. sorry to be so confused. i have been at this for hours and am having no luke.

    i would like the end result to be that the image is now stored in $img. so that it can be input into the update query. thanks for any hlep......

     

    mike

  9. i figured this out, you can use header as long as there is no other output before it. the input form and sql query have to be on separate pages with no out put till you either get to the correct page you are logging into or get to the error login page.

     

    thanks a bunch mike......

  10. i figured this one out, i had put:

     

    if(isset($_SESSION['username']))

    {

    unset($_SESSION['username']);;

    }

     

    in twice....

     

    when the second time i should have used:

     

    if($_SESSION['username'] != null)

    {

    unset($_SESSION['username']);;

    }

     

    to make sure that the session was unset before exiting the script.

    at least making this changed stoped the error....

     

    thanks mike.

  11. what does this mean and how do i fix it.

     

    Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

  12. I need some help getting started with a way to authenticate users as they sign on with there username and password. can somebody please point me in the right direction where i can find more info related to this.

     

    i have a php script that allows input of username and password and then checks them against values in another script. not sure that is the correct way.

     

    i also am currently using  <directory/my/directory/here></directory> style of authentication in apache config for my secure directory. this works and is secure, but is not very pleasing to the eye.

     

    thanks mike.....

     

  13. well i figured out  a fix, may not be the best way or only way but it works.

    here is what i added the the code above to fix my problem:

     

    City:                
    				<select id="city" name="city">
    				<?php if ($_SESSION['city'] != null)
    				{
    					$selected = $_SESSION['city'];
    					?> <option value="<?=$_SESSION['city']; ?>" >
    					<?php echo "$selected"; ?></option>
    					<?php
    					$selected = null;
    				}
    				?>
    				</select><br />
    				<br />
    

  14. ok. I have figured out sessions and how to use them. I am still having some problem though with my form that has option values. most of it works except that I use some javascript to control some of the options available depending choices that you make.

     

    first, the parts that work. the parts of the form that have actual option values in the form, the ones that you choose from first.

     

    the parts that do not work are the ones that are determined by your choice that was made first.

     

    i know this is confusing, not sure how to explain it.

    here is the code segment of the form.....

     

    <form method="post" action="<?=$_SERVER['PHP_SELF']?>">
    			State:              
    				<select  id="state" name="state" onchange="getCityList(this)">
    					<option value="">Select a state</option>
    					<option value="Alabama" <?if ($_SESSION['state'] == "Alabama") 
    					{echo 'selected="selected"'; } ?> >Alabama</option>
    					<option value="North Carolina" <?if ($_SESSION['state'] == "North Carolina") 
    					{echo 'selected="selected"'; } ?> >North Carolina</option>
    					<option value="Texas" <?if ($_SESSION['state'] == "Texas") 
    					{echo 'selected="selected"'; } ?> >Texas</option>
    				</select><br />
    				<br />
    			City:                
    				<select id="city" name="city">
    
    				</select><br />
    				<br />
    			Category:       
    				<select id="category" name="category" onchange="getSubCategoryList(this)">
    					<option value="">Select a category</option>
    					<option value="Auto">Auto</option>
    					<option value="Hotel">Hotel</option>
    					<option value="Restaurant">Restaurant</option>
    				</select><br />
    				<br />
    			SubCategory:
    				<select id="subcat" name="subcat">
    
    				</select><br />
    				<br />			
    			<input type="submit" name="submit" value="Select">
    	</form>
    

     

    in the code above, session works when the page reloads for state and category,

    but city and subcategory doesn't. not sure what to do there to get it to work.

    the form also uses validation to make sure that you have selected a state and a category.

     

    here is the entire form script:

     

    <?php
    session_start();  
    if(isset($_SESSION['state']))
    {
     unset($_SESSION['state']);;
    }
    else
    {
    $_SESSION['state'] = null;
    }
    if(isset($_SESSION['city']))
    {
     unset($_SESSION['city']);
    }
    else
    {
    $_SESSION['city'] = null;
    }
    if(isset($_SESSION['category']))
    {
     unset($_SESSION['category']);
    }
    else
    {
    $_SESSION['category'] = null;
    }
    if(isset($_SESSION['subcat']))
    {
     unset($_SESSION['subcat']);
    }
    else
    {
    $_SESSION['subcat'] = null;
    } 
    ?>
    <html>
    <head>
    
    <script language="javascript" type="text/javascript">
    <!-- 
    //Browser Support Code
    function ajaxFunction(){
    var ajaxRequest;  // The variable that makes Ajax possible!
    
    try{
    	// Opera 8.0+, Firefox, Safari
    	ajaxRequest = new XMLHttpRequest();
    } catch (e){
    	// Internet Explorer Browsers
    	try{
    		ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    	} catch (e) {
    		try{
    			ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    		} catch (e){
    			// Something went wrong
    			alert("Your browser broke!");
    			return false;
    		}
    	}
    }
    // Create a function that will receive data sent from the server
    ajaxRequest.onreadystatechange = function(){
    	if(ajaxRequest.readyState == 4){
    		document.myForm.city.value = ajaxRequest.responseText;
    	}
    }
    ajaxRequest.open("GET", "secondchoice.php", true);
    ajaxRequest.send(null); 
    
    }
    //-->
    </script>
    
    <script type="text/javascript" src="js/ajax.js"></script>
    <script type="text/javascript">
    
    var ajax = new Array();
    
    //this will refresh citys
    
    function getCityList(sel)
    {
    var stateCode = sel.options[sel.selectedIndex].value;
    document.getElementById('city').options.length = 0;	// Empty city select box
    if(stateCode.length>0){
    	var index = ajax.length;
    	ajax[index] = new sack();
    
    	ajax[index].requestFile = 'mygetcity.php?stateCode='+stateCode;	// Specifying which file to get
    	ajax[index].onCompletion = function(){ createCities(index) };	// Specify function that will be executed after file has been found
    	ajax[index].runAJAX();		// Execute AJAX function
    }
    }
    
    function createCities(index)
    {
    var obj = document.getElementById('city');
    eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
    }
    
    //this will get subcatagory
    
    function getSubCategoryList(sel)
    {
    var category = sel.options[sel.selectedIndex].value;
    document.getElementById('subcat').options.length = 0;	// Empty subcat select box
    if(category.length>0){
    	var index = ajax.length;
    	ajax[index] = new sack();
    
    	ajax[index].requestFile = 'mygetsubcat.php?category='+category;	// Specifying which file to get
    	ajax[index].onCompletion = function(){ createSubCategories(index) };	// Specify function that will be executed after file has been found
    	ajax[index].runAJAX();		// Execute AJAX function
    }
    }
    function createSubCategories(index)
    {
    var obj = document.getElementById('subcat');
    eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
    }		
    </script>
    
    <title>meo2000.net</title>
    <link rel="stylesheet" type="text/css" href="../web1.css" />
    <link rel="stylesheet" type="text/css" href="../heading.css" />
    <link rel="stylesheet" type="text/css" href="../navigation.css" />
    <link rel="stylesheet" type="text/css" href="directory.css" />
    
    </head>
    <body>
    
    <div class="navigation" id="navigation">
    	<a class="navjust" href="../index.php">Home</a><br />
    	<br />
    	<a class="navjust" href="http://mail.meo2000.net">Check Mail</a><br />
    	<br />
    	<a class="navjust" href="../web/webservice.php">Web Services</a><br />
    </div>
    
    <div id="justify">
    <div id="h">
    	<h1>meo2000 listing service</h1>
    	<h3>want to get listed, click <a href="getlisted.htm">here</a> to find out how.</h3>
    	<h3>This directory is under construction!</h3>
    	<br/>
    </div>
    </div>
    
    <?php
    Function DisplayForm($errors = null){
    $error_string = $errors; //state, you could use $error_string = implode ("<br />",$errors); if you want to save performance by using an array insead.
    	?>
    		<div id="left">
    		<span class="error">
    		<?=$error_string?><br />
    		</span>
    		<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
    			State:              
    				<select  id="state" name="state" onchange="getCityList(this)">
    					<option value="">Select a state</option>
    					<option value="Alabama" <?if ($_SESSION['state'] == "Alabama") 
    					{echo 'selected="selected"'; } ?> >Alabama</option>
    					<option value="North Carolina" <?if ($_SESSION['state'] == "North Carolina") 
    					{echo 'selected="selected"'; } ?> >North Carolina</option>
    					<option value="Texas" <?if ($_SESSION['state'] == "Texas") 
    					{echo 'selected="selected"'; } ?> >Texas</option>
    				</select><br />
    				<br />
    			City:                
    				<select id="city" name="city">
    
    				</select><br />
    				<br />
    			Category:       
    				<select id="category" name="category" onchange="getSubCategoryList(this)">
    					<option value="">Select a catagory</option>
    					<option value="Auto">Auto</option>
    					<option value="Hotel">Hotel</option>
    					<option value="Restaurant">Restaurant</option>
    				</select><br />
    				<br />
    			SubCategory:
    				<select id="subcat" name="subcat">
    
    				</select><br />
    				<br />			
    			<input type="submit" name="submit" value="Select">
    	</form>
    	</div>
    <?php
    }
    //check if form has been submitted
    if (!$_POST['submit'])
    {
    //if not display form
    DisplayForm();
    }
    else
    {
    //form has been submitted
    //items selected, check that number was entered,
     //Declare it so we dont get notices 'undeclared variable'
    $error = null;
    
    //set new session values.
    $_SESSION['state'] = $_POST['state'];
    $_SESSION['city'] = $_POST['city'];
    $_SESSION['category'] = $_POST['category'];
    $_SESSION['subcat'] = $_POST['subcat'];
    
    //check state has been selected
    if (trim($_POST['state']) == "") 
    	{	
    		$error .='ERROR: Please select a state.';
    	}
    //check category has been selected
    elseif (trim($_POST['category']) == "")
    	{
    		$error .='ERROR: Please select a category.';
    	}
    //if there was an error, show it.
    if ($error != null){
    	DisplayForm($error);
    	}
    else
    	{
    	//otherwise carry on?
    		echo '<div id="right">';
    		$state = $_POST['state'];
    		$city = $_POST['city'];
    		$cat = $_POST['category'];
    		$subcat = $_POST['subcat']; 
    			echo 'Here is your selections: <br />';
    			echo "<i>$state</i><br />";
    			echo "<i>$city</i><br />";
    			echo "<i>$cat</i><br />";
    			echo "<i>$subcat</i><br />";
    		echo '</div>';
    	}
    }
    //clear session values.
    if(isset($_SESSION['state']))
        unset($_SESSION['state']);
    if(isset($_SESSION['city']))
        unset($_SESSION['city']);
    if(isset($_SESSION['categoryt']))
        unset($_SESSION['category']);
    if(isset($_SESSION['subcat']))
        unset($_SESSION['subcat']);    
    ?>
    
    <div class="addspace" id="addspace">
    <p class="none" id="addmargin">
    	your<br >
    	add<br >
    	could<br >
    	be<br >
    	filling<br >
    	this<br >
    	spot!
    </p>
    </div>
    
    </body>
    </html>
    

     

    there is also a page that is accessed to get the city list after state is selected.

    here it is:

    <?php
    
    if(isset($_GET['stateCode'])){
      
      switch($_GET['stateCode']){
        
        case "Alabama":
          echo "obj.options[obj.options.length] = new Option('Birmingham');\n";
          echo "obj.options[obj.options.length] = new Option('Huntsville');\n";
          echo "obj.options[obj.options.length] = new Option('Mobile');\n";
          echo "obj.options[obj.options.length] = new Option('Montgomery');\n";
          
          break;
        case "North Carolina":
          
          echo "obj.options[obj.options.length] = new Option('Charlotte');\n";
          echo "obj.options[obj.options.length] = new Option('Greensboro');\n";
          echo "obj.options[obj.options.length] = new Option('Raleigh');\n";
          echo "obj.options[obj.options.length] = new Option('Wilmington');\n";
          
          break;
        case "Texas":
          
          echo "obj.options[obj.options.length] = new Option('Austin');\n";
          echo "obj.options[obj.options.length] = new Option('Dallas');\n";
          echo "obj.options[obj.options.length] = new Option('Houston');\n";
          echo "obj.options[obj.options.length] = new Option('San Antonio');\n";
          
          break;
      }  
    }
    
    ?> 
    

     

    and the code for that gets the subcat value:

    <?php
    
    if(isset($_GET['category'])){
      
      switch($_GET['category']){
        
        case "Auto":
          echo "obj.options[obj.options.length] = new Option('New');\n";
          echo "obj.options[obj.options.length] = new Option('Used');\n";
          echo "obj.options[obj.options.length] = new Option('Parts');\n";
          echo "obj.options[obj.options.length] = new Option('Repair');\n";
          
          break;
        case "Hotel":
          
          echo "obj.options[obj.options.length] = new Option(' ');\n";
          
          break;
        case "Restaurant":
          
          echo "obj.options[obj.options.length] = new Option('Fast Food');\n";
          echo "obj.options[obj.options.length] = new Option('Bar B Que');\n";
          echo "obj.options[obj.options.length] = new Option('Italian');\n";
          echo "obj.options[obj.options.length] = new Option('Sea Food');\n";
          
          break;
      }  
    }
    
    ?> 
    

  15. ok i added this and it seams to work. till get that global error though:

     

    [b]<?php
    session_start();  
    if(isset($_SESSION['name']))
    {
    echo $_SESSION['name'];
    }
    else
    {
    $_SESSION['name'] = null;
    } 
    ?>
    [/b]
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="web1.css" >
    <link rel="stylesheet" type="text/css" href="heading.css" >
    <link rel="stylesheet" type="text/css" href="navigation.css" >
    </head>
    <body>
    
    <div class="navigation" id="navigation">
    	<a class="navjust" href="index.php">home</a><br >
    	<br >		
    </div>
    
    <?php
    //check if form has been submitted
    if (!$_POST['submit'])
    {
    //if not display form
    ?>
    <div id="justify">
    <form method="POST" action="<?=$_SERVER['PHP_SELF']?>">
    please enter your name:
    	<input type="text" name="name" size="15"[b] value="<?=$_SESSION['name']?>[/b]"><br >
    	<br >
    <input type="submit" name="submit" value="Select">
    </form></div><br>
    <?php
    }
    else
    {
    [b]$_SESSION['name'] = $_POST['name'];[/b]
    echo '<div id="justify">';
    echo '<p class="top">';
    $name = $_POST['name']; 
    echo "$name <br >";
    echo '</p>';
    echo '</div>';
    }
    ?>
    
    </body>
    </html>
    

  16. i also get this error the first time i click submit:

     

    Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

     

    i am using php5

  17. ok i created this simple form,:

     

    <?php
    session_start();  
    if(isset($_SESSION['name']))
    {
        $_POST['name'] = $_SESSION['name'];
    }
    else
    {
        $_SESSION['name'] = null;
    }
    echo $_SESSION['name']; 
    ?>
    
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="web1.css" >
    <link rel="stylesheet" type="text/css" href="heading.css" >
    <link rel="stylesheet" type="text/css" href="navigation.css" >
    </head>
    <body>
    
    <div class="navigation" id="navigation">
    	<a class="navjust" href="index.php">home</a><br >
    	<br >		
    </div>
    
    <?php
    //check if form has been submitted
    if (!$_POST['submit'])
    {
    //if not display form
    ?>
    <div id="justify">
    <form method="POST" action="<?=$_SERVER['PHP_SELF']?>">
    please enter your name:
    	<input type="text" name="name" size="15"><br >
    	<br >
    <input type="submit" name="submit" value="Select">
    </form></div><br>
    <?php
    }
    else
    {
    echo '<div id="justify">';
    echo '<p class="top">';
    $name = $_POST['name']; 
    echo "$name <br >";
    echo '</p>';
    echo '</div>';
    }
    ?>
    
    </body>
    </html>
    

     

    and after entering a name in the input box and submitting it displays the name, then i can click on the home link and go back to my home page. then if i click on the link to go back to this same form, it will display the name i put in the box the first time at the top of the page. but i want it to put it back in the box again. how would i do that.

     

    also now everytime i visit the page no matter what i type in the box it still displays what i put in the first time, even after i submit it.......

     

     

  18. i think that you might misunderstand what i am trying to say. i get the idea behind sessions. i understand how they work.

     

    in this example:

    <?php
    session_start(); 
    $_SESSION['views'] = 1; // store session data
    echo "Pageviews = ". $_SESSION['views']; //retrieve data
    ?>
    

    i understand how it assigns a value of 1 to views, and the echo command displays the count.

     

    i also understand that in this example:

    <?php
    session_start();  
    if(isset($_SESSION['views']))
        $_SESSION['views'] = $_SESSION['views']+ 1;
    else
        $_SESSION['views'] = 1;
    
    echo "views = ". $_SESSION['views']; 
    ?>
    

     

    we first check if views has already been set and if so we add 1 to it, if not then views equal 1. then we once again display the value of views.

     

    i get the basics. i am not asking for you to give me the answer.

    but all of these examples we directly assign a value, and then echo it back.

    what i do not get is does all this have to be at the top of the page or can it be mixed into my form  or what.... that is what i dont get.......

     

    thanks mike.......

  19. that is good, and i have seen the how-to that you linked at tigzag.com. i must be missing something, or i just dont get it.

     

    i have a form like the one below, this form uses validation to make sure that a user has filled in all the input fields. if not the form reloads and i would like for the user to not have to fill in the entire form again. could somebody show me how to add sessions to make this happen. here is the sample form.

     

    <html>
    <head>
    
    
    </head>
    <body>
    <?php
    Function DisplayForm($errors = null){
    $error_string = $errors; 
    		echo('
    		'.$error_string.'<br />
    	please enter your name:
    		<input type="text" name="name" size="15"><br >
    		<br >
    	Please enter a number between 1 and 10:
    		<input type="text" name="num" size="2">
    		<br />			
    	<input type="submit" name="submit" value="Select">
    	</form>
    ');
    }
    //check if form has been submitted
    if (!$_POST['submit'])
    {
    //if not display form
    DisplayForm();
    }
    else
    {
    //form has been submitted
    //items selected, check that number was entered,
    $error = null; //Declare it so we dont get notices 'undeclared variable'
    
    //check number range
    if (!isset($_POST['num']) || !is_numeric($_POST['num'])) 
    	{	
    		$error .='ERROR: Please enter a number between 1 and 10';
    	}
    elseif ($_POST['num'] < 1 || $_POST['num'] > 10)
    	{
    		$error .='ERROR: The number must be between 1 and 10';
    	}
    //if there was an error, show it.
    if ($error != null){
    	DisplayForm($error);
    	}
    	else
    	{
    	//otherwise carry on?
    $name = $_POST['name'];
    $num = $_POST['num']; 
    	echo 'Here is your selections: <br />';
    	echo "<i>$name</i><br />";
    	echo "<i>$num</i><br />";
    	}
    }
    ?>
    
    </body>
    </html>
    

  20. as i have no clue how to use sessions, could somebody give me and example using this simple form please. I have read many how-to-s on the topic but the ones i have found give little info on how to actually use them. i need an example to get me started.

     

    <html>
    <head></head>
    <body>
    <?php
    //check if form has been submitted
    if (!$_POST['submit'])
    {
    //if not display form
    ?>
    <form method="POST" action="<?=$_SERVER['PHP_SELF']?>">
    please enter your name:
    	<input type="text" name="name" size="15"><br >
    	<br >
    <input type="submit" name="submit" value="Select">
    </form><br>
    <?php
    }
    else
    {
    $name = $_POST['name']; 
    echo "$name <br >";
    }
    ?>
    
    </body>
    </html>
    

     

    thanks in advance, mike.....

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