Search code examples
javascriptfirebasefirebase-hostingfirebase-dynamic-links

Can we use dynamic link without a firebase hosted webpage?


This might be a weird question, but first let me tell my problem. I have a contact form which is written in php . And after i completed the work, i get to this point that firebase does not support php code. So i need a Solution for that. There are this case that i just hoste my website with another server. Problem here i use dynamic links. So is it possible to use dynamic links with a webpage which is not hosted on firebase?

Solution 2. I rewrite the code . But the in which language? I domt wanna use cloud functions. I wanna use for example javascript. Is this possible?

If you have also any other solution please write them below. Thanks for answering the questions.

this is my code


<section id="page-details">
                <div class="container">
                    <div id="contact-details" class="full-width">
                        <div class="one-third">
                            <div id="contact-us-form" class="grey-corner-box">
                                <form action="contact-from-handler.php" method="post" class="contact-form init" novalidate="novalidate" data-status="init">
                                    <fieldset>
                                        <legend>
                                            <div>
                                                <span class="bold">Drop</span> us a line
                                            </div>

                                            <?php
                                            $contact_name = $contact_email = $contact_website = $contact_message = '';

                                            if(isset($_REQUEST['error']))
                                            {
                                                $contact_name    = $_REQUEST['contact_name'];
                                                $contact_email   = $_REQUEST['contact_email'];
                                                $contact_website = $_REQUEST['contact_website'];
                                                $contact_message = $_REQUEST['contact_message'];
                                            }
                                            ?>

                                            <?php if(isset($_REQUEST['error'])) { ?>
                                                <div style="background:red;color:white;padding:5px;margin:5px 0;clear:both;font-size:14px;">Some required field was missing!</div>
                                            <?php } elseif(isset($_REQUEST['success'])) { ?>
                                                <div style="background:green;color:white;padding:5px;margin:5px 0;clear:both;font-size:14px;">Successfully send your request!</div>
                                            <?php } ?>
                                        </legend>

                                        <ul>
                                            <li class="select-three">
                                                <div>
                                                    <label for="input-name">Name:*</label>
                                                    <input type="text" name="contact_name" value="<?php echo $contact_name; ?>" size="40" class="form-control default-input" aria-invalid="false">
                                                </div>
                                                <div>
                                                    <label for="input-email">E-mail:*</label>
                                                    <input type="email" name="contact_email" value="<?php echo $contact_email; ?>" size="40" class="form-control input-email default-input" aria-invalid="false">
                                                </div>
                                                <div>
                                                    <label for="input-website">Website:*</label>
                                                    <input type="text" name="contact_website" value="<?php echo $contact_website; ?>" size="40" class="form-control default-input" aria-invalid="false">
                                                </div>
                                            </li>
                                            <li>
                                                <div>
                                                    <label for="contact_message">Message:*</label>
                                                    <textarea name="contact_message" cols="40" rows="5" class="form-control textarea form-control" aria-invalid="false"><?php echo $contact_message; ?></textarea>
                                                </div>
                                            </li>
                                            <li>
                                                <div class="submit-contact default-submit">
                                                    <input type="submit" value="Submit" class="submit-btn theme-btn">
                                                </div>
                                            </li>
                                        </ul>
                                    </fieldset>
                                </form>
                            </div>
                        </div>

and then the contact-us-form


<?php
if(isset($_POST) && !empty($_POST))
{
    $data = $_POST;
    $data['email_receiver'] = "emsilll";
    

    $error = FALSE;
    if(!$_POST['contact_name'])
    {
        $error = TRUE;
        $field = 'contact_name';
    }
    elseif(!$_POST['contact_email'])
    {
        $error = TRUE;
        $field = 'contact_email';
    }
    elseif(!$_POST['contact_website'])
    {
        $error = TRUE;
        $field = 'contact_website';
    }
    elseif(!$_POST['contact_message'])
    {
        $error = TRUE;
        $field = 'contact_message';
    }

    if($error)
    {
        header('location:contact-us.php?error=yes&' . http_build_query($data));
        die();
    }

    $to      = $data['email_receiver'];
    $from    = "info@" . $_SERVER['SERVER_NAME'];
    $subject = "Subject: " . $data['contact_name'] . "";
    $message = "E-Mail: " . $data["contact_email"] . "\n" . $message = "Website: " . $data["contact_website"] . "\n" . "Message: " . $data["contact_message"];
    $headers = "From: " . $from . "" . "\r\n" . "Reply-To: " . $from . "" . "\r\n" . 'X-Mailer: PHP/' . phpversion();
    mail($to, $subject, $message, $headers);
    
    header('location:contact-us.php?success=yes');
}
?>


Solution

  • Firebase Dynamic Links don't have to be on the same domain as your website. It's common practice to host them on a different domain, or on a subdomain. The actual web forwarding address of the Dynamic link is specifying by the link parameter [1], and doesn't have to be the same as the domain of the Dynamic link.

    Firebase provides a free <subdomain>.page.link domain for your usage [2]. You can also setup dynamic links with a custom domain at <subdomain>.yourdomain.com or <subdomain>.yourdomain.com/path[3], which uses Firebase Hosting.

    If you would like to switch your entire website over to Firebase Hosting to take advantage of our other features (like the CDN), you can setup your PHP site to run on Cloud Run [4], and setup a rewrite to it using Hosting [5].