How do I get the user's input from a .html file to a .c file? - html

I'm trying to get the input from my html webpage, which has a text box and submit button. How can I get the user's input in a separate .c file, so that I can change what happens in my html file depending on the input?
Here is the problem for my assignment:
If the player input the word NORTH, SOUTH, EAST, or WEST, the program will programmatically generate a webpage that hyperlinks to another room. Do printf() to the browser.
You will need to do something like this:
printf(“< a href=\”http://URL\”>Press HERE to go North< /a>”);
The above printf() will display on the browser a hyperlink. The player will simply click on the word Press HERE to go North with their mouse to cause the browser to change to another webpage. The HTML tag to link to another webpage is:
< a href=”URL”>TEXT TO CLICK< /a>.
You will need to do this for each direction: NORTH, SOUTH, EAST and WEST. If the player input the word GOLD, the program will programmatically generate a webpage that displays the amount of gold pieces the player currently owns and a hyperlink to return the player back to the current room.

Might need a little bit more clarification on what exactly it is you're trying to achieve, but if you do actually want the HTML file to change based on the user's input, depending on whether you want that change to be permanent or based on the individual user, you have a couple of options:
1) If you want the user's input to permanently change the HTML file, have it posted to another server-side page on your website (PHP for example) -- then take the user's input and you can use PHP to write actual changes to the HTML file stored on the server which is delivered to your end users. I would advise being very careful with this and make sure you sanitise the input properly to avoid security issues.
2) Alternatively if you want the user's input to change the page they're viewing in some way in real-time and only for that user, you probably want to make use of JavaScript and set the innerHTML of elements based on the user's input.
If you clarify a little more in the comments for this answer what exactly you're trying to achieve, I can give more specific help.

Related

Display Contents After Correct User Input

I'm a beginner in web dev but I'm really good on the software end. I have some HTML to display text and a YoutTube Video on a webpage. But before this, the user must be prompted to input a value in a text box.
What I wanted is for the user to see a box with a submit button. The box will only accept one of 7000 unique entries. Once the user inputs one of the 7000 entires, only then the HTML/YouTube Video must be displayed. Otherwise the page can display a message saying: Retry, entry not recognized.
The webpage is running Wordpress with Motopress. Is there anyway I can do this with Custom fields to store the values or whichever way is easy and quick?

How to find same logos, UI elements using sikulix

I am new to sikuli.
I am using it for functional test automation of my java spring standalone application. I am having the same set of images(logos) at multiple locations on the screen. and they are generated dynamically as per the application data. In that case how can I find and click on certain buttons/elements in the UI.
Example: like, share, comment text/image will be there several times in facebook page. in that how to we click on particular buttons out of all.(facebook is just an example) i want the similar solution for my application.
I think what you're asking is- given a case where the same image or UI element is present multiple times on the same page, how can I specify one of these elements in one location versus the same element in another?
The quick and easy way to do this would be to capture a larger picture, like as much of the window as you can, and click the image in parentheses after the click action; this opens a window reading file, matching preview, and target offset. Click target offset, use the mouse wheel to zoom in, and click on the exact point of the picture that you'd like to click.
It's possible to click in multiple places on a captured image, provided you use different click() commands, and you can set the target offset for each click() command without needing a new picture.
With just this one image, you can potentially click every square on the board provided you take the time to set the offset for each of the 64 click() commands it'd take to do so. http://files.chesscomfiles.com/images_users/tiny_mce/cigoL/Chessboard.png
The more difficult solution would be setting up regions, and searching those regions for the matching pictures, but for what you're looking for this should- for more about regions and setting it up check links below. Cheers!
http://sikulix-2014.readthedocs.io/en/latest/index.html
Based on your FB example you could use setROI() to focus on the top post on the page (imagine a rectangle that covers a complete post on the news feed) from there I would loop:
if exists(profile pic):
click(like button)
elif exists(profile pic 2): # If you are testing more than one user
click(like button)
else : type(Key.DOWN) #repeat as needed
Getting the next post into the ROI may be tricky but using WHEEL_DOWN may help if you can adjust your lines traveled with each wheel click on your system.

click through several links on webpage and extract information from each?

I have access a webpage with a list of several hyperlinks, each of which are unique. This is it:
webpage I have access to that lists names from top to bottom. Each name is unique and is a hyperlink. I would like to click on these hyperlinks one by one and extract info from the resulting webpage.
Say I click the first name, say Adam, it then brings me to the following webpage:
alt:this is a page of the user's profile and includes info such as name, email status and more
My goal is to create a program that clicks the name at the top, and then takes the email address and puts it in an excel spreadsheet on my local machine. And then goes back to the original page, clicks on the name directly below the name that was previously clicked on, and then takes this names resulting email and throws it in the spreadsheet.
for those looking at the pictures, i would like to click on 'Adam' and then put his email into a spreadsheet, then go back, and then click on 'Adrian' and then put his email into a spreadsheet, and so on and so forth down the list.
What do I need to do/learn to create a tool that will do this for me?
I know a bit of Java and a tiny bit of html. I've been trying to look for a solution but the most I can get is excel vba to click on the first name, but not much more. Even if I got the vba to click on all the names, it seems I would have to type in an instruction for the vba to find each unique name, and I dont see much point in doing that since its probably faster to just do this manually then.
As i'm not a programmer (but would like to be soon :)) I have had some trouble asking this question since I don't know any technical terms.
Any thoughts/advice on how to do this?
With javascript and a little php you could make this happen. Since it appears this is something running in the browser it would probably be your best bet.
Make your program click links js has the ability to activate links. You could
click on body load
the first link on the page,
then have a counter that counts each time you click a link.
`Find out how many links there are in the document:`
var x = document.links.length;`
`Get the URL of the first link (index 0) in the document:`
`var x = document.links[0].href;`
Click the link you want to click
$(function(){
$('#myLink').trigger('click');
})
now that your on the next page you need to grab the email address that is on this page. If you know the css just grab the string that is in the element. at this point you can use javascript to go back to the previous page.
<button onclick="goBack()">Go Back</button>
Now you are on the original page. Your counter is one number higher. Use the counter to click the next link and your program will repeat the process pushing the new email to your array.
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
once the program runs out of links to click or hits the limit of your counter you will need to create a txt file with javascript. write your array to the file with PHP. You can do this with an ajax call.
make an AJAX call to your php file passing the array. php can then write to the file.
Here is an example of making a text file and writing to it with javascript
Following this logic you can fairly easy make an application that activates the links in order of a page, pushes the email address to an array as a string. Goes back to the previous page and continues the process till you have all the links. At this point your program will write all the data in the array to a file.

saving content editable html for Google Earth application

I just started working with html, and I am creating balloon description templates for Google Earth. I am creating site logs for gps locations around the world, and these sites get updated every now and then with a new receiver or antenna.
I have a table set up with all the information about the equipment we have at these sites, and I want to be able to change values in the table when the equipment is changed.
Right now the only way to do that is to go into the html code and find the specific value you need to change and then save the new html code. This works, but it would be nice if I could edit the values without having to go into the code. I know you can do contenteditable=true and then have some text you can edit, but when you refresh the page it goes back to the orignal text.
My question is if there is a way to edit the html code permanently without actually going through all the lines of code to find the one thing you want to change. If this cannot be done, or if my question makes no sense let me know. I probably just need to work with this stuff for more than a week.

URL form retrieval and submission via flash?

Totally new to flash and actionscript. What I want to do is retrieve a URL into a page (probably in a hidden frame or something), populate the form it contains with the correct fields (via my script), including possible data to upload, then submit it back. I guess an analogy use-case would be if I had a user choose a picture and then which site to upload it to (tinypic, flickr, etc), the script would download the main page, fill in the form data, attach the pic, and submit it. I saw a similar example in php somewhere, but I need to do it in flash.
I can probably get it eventually by myself, but if someone could point me in the right direction (keywords, functions to use/avoid, etc) I'd really appreciate it!
Rather than retrieving the form and trying to fill it out just use actionscript to directly post to the server side script.