Ask coding questions

← Back to all posts
Connecting repls in html, css, and javascript
MikeJMS8910 (234)

So what I want to do is have one repl where you fill out the information and when you press solve it opens up a new repl in a new tab with all of the information filled out. How will I be able to do this where they share the same database and variables.

Answered by TalinSharma (77) [earned 5 cycles]
View Answer
TalinSharma (77)

I don't know about the database thing on Repl but this is what you may do:

This example has username and email inputs:


<form action='PHP LINK' method='post'>
    <input type='text' name='user' required>
    <input type='email' name='email' required>
    <input type='submit'>


$user = $_POST['user'];
$email = $_POST['email'];
$msg = "Your Username Is: ".$user."<br><br>"."Your Email Is: ".$email;
echo $msg;

Don't forget to put the HTML in an HTML Repl and the PHP code in a PHP Web Server Repl... Like with the HTML repl, how you open up the website in the new tab, do it with the PHP Repl, and copy the URL... Then take away PHP LINK from the form action and replace it with the URL you copied.

When you submit the form it should tell you what you submitted.

I suggest you find a PHP tutorial and learn from there. PHP is for form processing but it can do so much more! Learn it!

Let me know if something goes wrong!

P.S. When you are copying and pasting the PHP code to the Repl, take away the <?php, ?>, and whatever it has between it!

P.P.S If you don't want to learn PHP or use it, I can show you an example of how to do this in JavaScript... Just tell me!

MikeJMS8910 (234)

@TalinSharma actually how would I do this in javascript

TalinSharma (77)

Could you invite me to your Repl?



MikeJMS8910 (234)

@TalinSharma can you just make an example repl and share it to me?

TalinSharma (77)

Alright! I will share it with you!


CodingCactus (4336)

you will need some form of backend for this, using something like express for js or flask for py (or PHP if you wat to die)


An idea: Simply make all the solving parts a whole div, and make all the filled out information another div. then in the JS, you can hide the first div and show the second.

MikeJMS8910 (234)

@LAMAQDAHODWALA I would do that but I want it to open in a new tab and keep the old one

MikeJMS8910 (234)

@TalinSharma Well if you were to open in a new tab then the code would reset so there wouldn't be a trigger.

TalinSharma (77)

Do you mean when you are copying and pasting the PHP URL? Yeah, there wouldn't be... You are just copying and pasting...


TalinSharma (77)

Yeah it will be... You just have to do the copying and pasting one time to get the URL for the form action then when you paste, every time you use the form you will get the result... Why don't you invite me to your reply and I can show you what I mean?