Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
    Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

HTML form and PHP

 
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
no, I want once it's is submitted it should add item as per problem description so for same i have written code as well and shared code as well but the problem is nothing is happening when i click submit button.
Ideally some thing like item should be added as per written code but it's not doing intended task.
 
Saloon Keeper
Posts: 6448
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator

nothing is happening when i click submit button.


Yes, and that is because nothing CAN happen because the form has no action attribute, as Stephan said. You REALLY need to start paying CLOSE attention to what we say.

what to correct to resove my issue at the earliest now?


Quite frankly, given the rate at which this is progressing, I suspect that "the earliest" is a long time off, and you should be prepared for that.
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
when i enter localhost/v1 then i get directory path and when i select my html form to upload some image and then click submit button nothing happen,please refer attached screen shots for more clarification.
error.png
[Thumbnail for error.png]
directory.png
[Thumbnail for directory.png]
im1.png
[Thumbnail for im1.png]
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
ok,

I paid attention and came to understand that in html web form i need to write some code like below after it's heading part  -->




Kindly advise was my understanding correct here ,I also reffered this example  https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_form_action

Thanks much..
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
but after uploading image as shared in previous screen shot 'im1' and then clicking on submit button and even afater adding that code line <form action="/additem.php">

I get the attached error now.

object-not-found.png
[Thumbnail for object-not-found.png]
 
Tim Moores
Saloon Keeper
Posts: 6448
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator
What is that slash ("/") doing there? All the files are in the "v1" directory, so if anything, it should be "/v1/additem.php", but even better, just remove the slash to indicate that the form and its action target are both in the same directory.

And just to state the obvious, there should only be a single form element, not two.
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
ok,I modified it as --> <form action="v1/additem.php"> but still the same error ('Object not found !') and i have only one form this time  in this v1 folder now still  the same error.

please refer the attached screen shots for more information on the same.

modified code of form1.html file :-





Thanks

object-not-found.png
[Thumbnail for object-not-found.png]
v1-folder.png
[Thumbnail for v1-folder.png]
 
Saloon Keeper
Posts: 12022
257
  • Mark post as helpful
  • send pies
  • Report post to moderator
You really should be able to draw a logic conclusion from what URL the browser went to. What do you think your form's action really should be, if right now the URL is http://localhost/v1/v1/additem.php?
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
if i click on this link http://localhost/v1/v1/additem.php i get same error ('object not found !') as  attached here.


Thanks
object-not-found.png
[Thumbnail for object-not-found.png]
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
if you meant to ask what action should be then i think action should ideally be to execute the code for additem ,if that what you meant to point here?
 
Tim Moores
Saloon Keeper
Posts: 6448
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator

Tim Moores wrote:You REALLY need to start paying CLOSE attention to what we say.



Tim Moores wrote:What is that slash ("/") doing there? All the files are in the "v1" directory, so if anything, it should be "/v1/additem.php", but even better, just remove the slash to indicate that the form and its action target are both in the same directory.

 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
ok,sorry i removed that slash ("/") now after removing slash code for form is like below and upon clicking submit button i get different screen this time ,attached is the screen shot for same reference.

error.png
[Thumbnail for error.png]
 
Tim Moores
Saloon Keeper
Posts: 6448
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator
I note that pretty much all PHP code on the web is wrapped in

That might be required here as well.

But I see no code that would handle an HTTP form submission, so I'm not sure what you would expect as output of this.
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
I would expect below code which i just modified as per advise after wrapping it inside <?php  and  ?> to add items in specific section for the specific URL(what we say here in main problem as item).

But now when i click on submit button i get different ' unexpected parse error' as shown in attached screen shot.






Thanks
unexpected-final-error.png
[Thumbnail for unexpected-final-error.png]
 
Stephan van Hulst
Saloon Keeper
Posts: 12022
257
  • Mark post as helpful
  • send pies
  • Report post to moderator

John Ken wrote:I would expect below code which i just modified as per advise


I didn't advise you to modify anything. I gave you some example code from which you can draw inspiration. I made a typo in that code, and you blindly copied it without understanding it.

There is a missing semicolon after the namespace declaration. However, even if the code was valid, it doesn't do anything because it's just a class declaration. You still need to put statements in your php file that will do something. They need to be outside the class declaration. And you really should not use a verb to name your class, a class is supposed to represent a thing so you should name it for a noun.
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
ok,I corrected it like below still same error "Parse error: syntax error, unexpected '(', expecting variable (T_VARIABLE) in F:\Java Training\SW\Netbeans\Xampp installation location\htdocs\v1\additem.php on line 18":-

Also I changed class name from additem to' aditem' to make it noun not a verb but how can i put statements in my php file that will do something for resolution of my main problem and They need to be outside the class declaration.
Kindly advise and below is the modified code.



Thanks much..

 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
in above pasted code in 2nd line i have made correction from additem to aditem still I am getting same error ""Parse error: syntax error, unexpected '(', expecting variable (T_VARIABLE) in F:\Java Training\SW\Netbeans\Xampp installation location\htdocs\v1\additem.php on line 18":-"

 
Stephan van Hulst
Saloon Keeper
Posts: 12022
257
  • Mark post as helpful
  • send pies
  • Report post to moderator
What is line 18 trying to express?
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
below is the line 18:- I am not sure where is this throwing error ""Parse error: syntax error, unexpected '(', expecting variable (T_VARIABLE) in F:\Java Training\SW\Netbeans\Xampp installation location\htdocs\v1\additem.php on line 18":-"" from?
public __construct(item $item, DateTimeImmutable $addDattime, int $numberOfItems, section $mainSection,logo $mainitem  {
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
whereas all these variales in line 18 are already prefixed with '$' sign.

still this error.
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
any updates by experts here on the same please?


Thanks
 
Stephan van Hulst
Saloon Keeper
Posts: 12022
257
  • Mark post as helpful
  • send pies
  • Report post to moderator
I asked you what line 18 is supposed to do.
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
it is customized as per modelling like your room booking example to mine item (url link adding)adding in section.
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
The construct function lets you use things over the entire class. This way you don't have to load the model/language/settings in every method.
 
Stephan van Hulst
Saloon Keeper
Posts: 12022
257
  • Mark post as helpful
  • send pies
  • Report post to moderator
If you had read the PHP documentation, you would have known it was called a constructor. You also would have known what was wrong with its declaration.

I suggest you read what the PHP manual says on constructors.
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.
Note: Parent constructors are not called implicitly if the child class defines a constructor. In order to run a parent constructor, a call to parent::__construct() within the child constructor is required. If the child does not define a constructor then it may be inherited from the parent class just like a normal class method (if it was not declared as private).

I have gone through manual still unable to figure out what is wrong here i just reffered your model for room booking and mae some custom changes for item adding in main section really not sure what is wrong here where as all
concepts of constructor have been nicely implemented here.
 
Stephan van Hulst
Saloon Keeper
Posts: 12022
257
  • Mark post as helpful
  • send pies
  • Report post to moderator

John Ken wrote:I have gone through manual still unable to figure out what is wrong here i just reffered your model for room booking and mae some custom changes for item adding in main section really not sure what is wrong here


Yes, you made changes to what I wrote, without understanding what it does. Tim and I have been trying to tell you that you need to understand the basics before you do anything like this. I wrote the example from the top of my head, without testing it because it was just meant to give you inspiration for how to write classes to represent your model.

If you had experience with PHP before, you would have known what was wrong with it, and you would have found the problem immediately. But you don't bother starting with the basics, you're just trying to modify code that somebody else wrote.

The examples in the part of the PHP manual that you referred to show working examples. Compare them to the constructor in your code, and you will find the syntax error.
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
Even after comparison I am unable to find out what is the error so need experts help to resolve my problem soon, as i have been trying very hard to resolve it but so far could not resolve it.
So if some expert could quickly help and resolve my error then it would be much helpful.


Thanks much..
 
Stephan van Hulst
Saloon Keeper
Posts: 12022
257
  • Mark post as helpful
  • send pies
  • Report post to moderator
If you compare the line from your code to a line from the examples in the manual, what is the very first word that is different between the two?
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
If I am not wrong we both are on this same web page as a referral :-

https://www.w3schools.com/php/php_oop_constructor.asp

and if i see above link as a referral then i find 'function' is the word which differentiate my code and their code,also in my code i have doubt on section ,logo and stream words.
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
any php expert is there to help me here please?

..Thanks
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
if there is any php expert who could quickly tweak my code to resolve my problem quickly,parallely i have also been trying but if there is any expert who could resolved it quickly then it would be much helpful.

Thanks much..
 
Tim Moores
Saloon Keeper
Posts: 6448
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator
I doubt that it would be helpful to you if someone fixed some problem or other in the code, because you wouldn't learn anything from that. This site is for people helping others to learn, but if someone is unwilling to sit down and think about what it is they're doing, and learn the basics (of PHP in this case), then there isn't much we're willing to do about that.

You may need to engage someone on a professional basis to work with you if you want spoon-feeding all the way
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
It's wrong assumption that I won't learn from that so far I have learnt a lot from experts and I am also very much willing to learn and have been sitting for past many days to learn and sort out my problem,but since many errors are coming  during resolution of my problem so I have been stuck for past many days to resolve it ,but I have not lost hope yet I still believe under experts guidance i will be able resolve it soon.

To continue on the last point I would like to follow up from that point :-
"If I am not wrong we both are on this same web page as a referral :-

https://www.w3schools.com/php/php_oop_constructor.asp

and if i see above link as a referral then i find 'function' is the word which differentiate my code and their code,also in my code i have doubt on section ,logo and stream words."

Thanks

 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
any updates by experts please?
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
https://www.youtube.com/watch?v=rVmZXJj5lH0

is this the solution of my problem?

Thanks
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
..just wondering only two experts are there who could advise on my problem where are other experts specially PHP ones?

Thanks
 
Tim Moores
Saloon Keeper
Posts: 6448
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator
This is primarily a Java site, not a PHP site. There are likely more lively PHP sites elsewhere.

Also, keep in mind that it is a weekend, and a holiday weekend in many countries
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Report post to moderator
ok,then any java expert is there who could help to solve my problem ?

thanks
 
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic