Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder
    Join Date
    Mar 2010
    Location
    Orlando, FL
    Posts
    159
    Thanks
    4
    Thanked 8 Times in 8 Posts

    action form command to php file

    I have a <form> element in one of my html files and the action="" command is supposed to send the textfield strings to a php file that's in the folder used to access mySQL via the localhost. Once the data gets to the php file, it will get put into mySQL. But when I hit the submit button, an error comes up and says it can't find C:/wamp/www/wamp/www/file.php. I have no idea why it's trying to look through two sets of the same file (/wamp/www). With WAMP I thought the file used to access the database was supposed to be in a specific location. Am I wrong? How can I fix all this?

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Sounds like you've used the wrong path in the form's action attribute. Show some code and maybe someone can confirm.
    Are you a Help Vampire?

  • #3
    Regular Coder
    Join Date
    Mar 2010
    Location
    Orlando, FL
    Posts
    159
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Ok. Here's the form section for the html file. Right now, all the files related to my website are in the folder where localhost pulls from.





    Code:
    <center>
    <script type="text/javascript">
    function notEmpty(elem, elem1, elem2, helperMsg, helperMsg2){
    	if(elem.value.length == 0){
    		alert(helperMsg);
    		elem.focus();
    		return false;
    	}
    	if(elem1.value.length == 0){
    		alert(helperMsg);
    		elem.focus();
    		return false;
    	}
    	if(elem2.value.length == 0){
    		alert(helperMsg);
    		elem.focus();
    		return false;
    	}
    	
    	var alphaExp = /^[a-zA-Z]+$/;
    	if(elem1.value.match(alphaExp)){
    	return true;
    		}else{
    		alert(helperMsg2);
    		elem.focus();
    		return false;
    	}
    
    return true;
    }
    
    </script> 
    <div id="main">
    <form align="center" method="post" action="wamp/www/recipesubmit.php">
    <font color="red"><i>* = Required Field</i></font>
    <table  border="0" bordercolor="darkblue">
    <tr><td align="right"><font color="red">*</font>Recipe Name:</td><td><input type='text' id='recipeName' size=50></td></tr>
    <tr><td></br></td></tr>
    <tr><td align="right"><font color="red">*</font>Ingredients:</td><td><input type='text' id='ingredients' size=50></td></tr>
    <tr><td></td><td><font font size="2" color="red">Reminder: </font><font font size="2">Make sure you put a space between each ingredient.</br>Example: <b>chicken cream of mushroom soup</b>. DO NOT PUT</br>MEASUREMENTS! It is also important to correctly spell the</br>ingredients otherwise your recipe may not be found when searched.</td></tr>
    <tr><td></br></td></tr>
    <tr><td align="right"><font color="red">*</font>Directions:</td><td><textarea id='description' cols=50 rows=10></textarea></td></tr>
    <tr><td></br></td></tr>
    <tr><td align="right"><font color="red">*</font>Cook/Prep Time:</td>
    <td><select name="cooktimedrop">
        <option value="zerofive">0-5</option>
        <option value="sixten">6-10</option>
        <option value="elevenfifteen">11-15</option>
        <option value="sixteentwenty">16-20</option>
        <option value="twentyonetwentyfive">21-25</option>
        <option value="twentysixthirty">26-30</option>
        <option value="thirtyonethirtyfive">31-35</option>
        <option value="thirtysixforty">36-40</option>
        <option value="fortyonefortyfive">41-45</option>
        <option value="fortysixfifty">46-50</option>
        <option value="fiftyonefiftyfive">51-55</option>
        <option value="fiftysixsixty">56-60</option>
        <option value="sixtyoneplus">61+</option>
    </select>  minutes</td>
    <tr><td></br></td></tr>
    <tr><td align="right"><font color="red">*</font>Genre:</td>
    <td><select name="genredrop">
        <option value="alcoholic">Alcoholic</option>
        <option value="appetizers">Appetizers</option>
        <option value="beverages">Beverages</option>
        <option value="breads">Breads</option>
        <option value="breakfast">Breakfast</option>
        <option value="cakes">Cakes</option>
        <option value="candies">Candies</option>
        <option value="casseroles">Casseroles</option>
        <option value="cookies">Cookies</option>
        <option value="crockpot">Crockpot</option>
        <option value="desserts">Desserts</option>
        <option value="dipsdressings">Dips/Dressings</option>
        <option value="entrees">Entrees</option>
        <option value="fatfree">Fat Free</option>
        <option value="georgeforeman">George Foreman</option>
        <option value="halal">Halal</option>
        <option value="herbal">Herbal</option>
        <option value="italian">Italian</option>
        <option value="jams">Jams</option>
        <option value="jello">Jell-O</option>
        <option value="lowfat">Low Fat</option>
        <option value="mexican">Mexican</option>
        <option value="puddings">Puddings</option>
        <option value="rice">Rice</option>
        <option value="salads">Salads</option>
        <option value="sauces">Sauces</option>
        <option value="seafood">Seafood</option>
        <option value="snacks">Snacks</option>
        <option value="soups">Soups</option>
        <option value="vegan">Vegan</option>
        <option value="vegetarian">Vegetarian</option>
    <tr><td></br></td></tr>
    <tr><td align="right">Submitted By:</td><td><input type='text' id='submittedBy' size=40></br></td></tr>
    <tr><td></br></td></tr>
    <tr><td></td><td align="right"><input type='submit' onclick="notEmpty(document.getElementById('recipeName'), document.getElementById('ingredients'), document.getElementById('description'),'You have not filled in all required fields.', 'I thought I said no measurements! (No Numbers)')" value='Submit Recipe'></td></tr>
    </form>
    </div>
    </center> 
    
    
          	  </div>

  • #4
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I reckon tomws is right.

    Code:
    <form align="center" method="post" action="wamp/www/recipesubmit.php">
    maybe this should rather be

    <form align="center" method="post" action="/wamp/www/recipesubmit.php">

    ?
    I *think* the problem is that you're relatively addressing your PHP. "wamp/www/" means "go from current directory (in general, server root) to wamp, then to www".
    That could explain the double path issue.
    Also try a plain "recipesubmit.php", I wonder if this works as well in your case.
    Last edited by syntax_error; 03-31-2010 at 11:14 AM.

  • #5
    Regular Coder
    Join Date
    Mar 2010
    Location
    Orlando, FL
    Posts
    159
    Thanks
    4
    Thanked 8 Times in 8 Posts
    I tried
    <form align="center" method="post" action="/wamp/www/recipesubmit.php">
    but it didn't work. It actually does absolutely nothing. When I press the submit button, nothing happens, as opposed to leaving off that first "/" which takes me to an error page.
    Now, i know for php files to communicate to mySQL the directory has to say "localhost" in the name. For example, in C:/wamp/www folder, I have a php file called phpmysqltest that I made to test the connection between php and mySQL. When typing the address into the browser, C:/wamp/www/phpmysqltest.php does not work. But changing it to localhost/phpmysqltest.php DOES work. But how do i specify that in the form?

  • #6
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    <form align="center" method="post" action="recipesubmit.php">

  • #7
    Regular Coder
    Join Date
    Mar 2010
    Location
    Orlando, FL
    Posts
    159
    Thanks
    4
    Thanked 8 Times in 8 Posts

    Exclamation

    That doesn't work because it looks through the same folder as the rest of my website's files.

  • #8
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Quote Originally Posted by wojo1086 View Post
    That doesn't work because it looks through the same folder as the rest of my website's files.
    But that's where you were trying to direct it before, yes?
    Code:
    <form align="center" method="post" action="wamp/www/recipesubmit.php">
    Are you a Help Vampire?

  • #9
    Regular Coder
    Join Date
    Mar 2010
    Location
    Orlando, FL
    Posts
    159
    Thanks
    4
    Thanked 8 Times in 8 Posts

    Exclamation

    No. All the files that are used by my website are kept in a folder on my desktop. The only file in the C:/wamp/www folder is the one the action command is trying to access. If I use this...

    Code:
    <form align="center" method="post" action="wamp/www/recipesubmit.php">
    ...the place the action command is looking for the file is C:.../desktop/website/wamp/www/file.php.
    If I use...

    Code:
    <form align="center" method="post" action="/wamp/www/recipesubmit.php">
    ..nothing happens. The submit button doesn't do anything. The page stays on the screen just as it was.

  • #10
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    wamp/www/recipesubmit.php is relative to the current directory - the directory where the form is sitting. That won't work.

    /wamp/www/recipesubmit.php is relative to the website root directory. That won't work.

    Why do you have files tossed all around the filesystem? That's going to screw things up and is not an accurate representation of a folder structure on a web host. If you'll put everything in standard locations, this will be infinitely easier.
    Are you a Help Vampire?

  • #11
    Regular Coder
    Join Date
    Mar 2010
    Location
    Orlando, FL
    Posts
    159
    Thanks
    4
    Thanked 8 Times in 8 Posts
    The files are in two different locations. One file is in the /wamp/www folder and the rest are in a folder on my desktop. Should I put all the files in the /wamp/www folder? Or is there a better place?

  • #12
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Quote Originally Posted by wojo1086 View Post
    Should I put all the files in the /wamp/www folder?
    Yes. I'm not sure, but I suspect the WAMP docs would have said that.
    Are you a Help Vampire?

  • #13
    Regular Coder
    Join Date
    Mar 2010
    Location
    Orlando, FL
    Posts
    159
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Sorry about that cross-post. I figured out how to make it work. Thanks for the help.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •